It is ppassig the custom input,but not the test case

#include
using namespace std;

long long int maxsum(long long int a[],long long int n);
long long int kadane(long long int a[],long long int n);

int main()
{
long long int n,a[1000000],m,t;
cin>>t;
while(t–)
{
cin>>n;

for(int i=0;i<n;i++)
{
	cin>>a[i];
}
m=maxsum(a,n);
cout<<m;
}

}

long long int kadane(long long int a[],long long int n)
{ long long int cs=0;
long long int ms=0;

for(int i=0;i<n;i++)
{
cs=cs+a[i];

if(cs<0)
{ cs=0;
}
ms=max(cs,ms);

}

return ms;
}

long long int maxsum(long long int a[],long long int n)
{ long long int totsum=0;

long long int maxarr=kadane(a,n);


for(int i=0;i<n;i++){
	
	totsum=totsum+a[i];
	
}

	for(int i=0;i<n;i++){
	
	a[i]=-a[i];
}

long long int maxarr1=kadane(a,n);
long long int maxarr2=totsum+maxarr1;

return(max(maxarr,maxarr2));


}

Hello @apurvaraina99,

The logic of your code is correct.
It is producing the right outputs also.

Then, why is it showing wrong output.

This is due to a basic mistake that everyone does.
The Output Format. You have to print values of m for different arrays at different lines.

Hope, this would would help.
Give a like, if you are satisfied.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.