import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for(int i =0;i<t;i++)
{
int n = sc.nextInt();
int a[]=new int[n];
for(int j =0;j<n;j++) {
a[j]=sc.nextInt();
}
summax(a, n);
}
}
public static void summax(int []ar,int n) {
int sum =0;
int max =0;
for(int i =0;i<n;i++)
{
for(int j =i;j<n;j++) {
for(int k =i;k<=j;k++) {
sum =sum+ar[k];
if(sum>max) {
max = sum;
}
}
}
}
System.out.println(max);
}
}