mport java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner scn = new Scanner(System.in);
int m = scn.nextInt();
for (int z = 0; z < m; z++) {
int n = scn.nextInt();
int[] arr = new int[n];
for (int i = 0; i < arr.length; i++) {
arr[i] = scn.nextInt();
}
int max = Integer.MIN_VALUE;
for (int a = 0; a < arr.length; a++) {
int x = arr[a];
if (x > max)
max = x;
int s = 0;
for (int b = a + 1; b < arr.length; b++) {
s = x + arr[b];
if (s > max) {
max = s;
}
x = s;
}
}
System.out.println(max);
}
}
}