import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int test = sc.nextInt();
int counter = 1 ;
while (test != counter){
int arSize = sc.nextInt();
int[] arr = new int[arSize];
for (int i = 0; i < arSize; i++) {
arr[i] = sc.nextInt();
}
result(arr);
counter++;
}
}
static int maxSubArraySum = Integer.MIN_VALUE;
static void result(int[] arr) {
int maxSubArraySum = arr[0];
int cur_sum = maxSubArraySum;
for (int i = 1; i < arr.length; i++) {
cur_sum = Math.max(arr[i] + cur_sum, arr[i]);
maxSubArraySum = Math.max(cur_sum, maxSubArraySum);
}
System.out.println(maxSubArraySum);
}
}