while submitting it is showing wrong answer
code:
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
int i,j;
for(i=0;i<t;i++)
{
int n=sc.nextInt();
int a[]=new int[n];
for(j=0;j<n;j++)
{
a[j]=sc.nextInt();
}
int max=0;
int newmax=0;
for(int p=0;p<n;p++)
{
max=max+a[p];
newmax=Math.max(max,newmax);
if(max<0)
max=0;
max=newmax;
}
System.out.println(max);
}
}
}