#include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef struct hold{
int x = -1,y = -1;
int val = -1;
}hold;
hold maxSumSub(int *arr,int s,int e){
if(s==e){
hold temp;
temp.val = arr[s];
temp.x = temp.y = s;
return temp;
}
int mid = (s+e)/2;
hold h1 = maxSumSub(arr,s,mid);
hold h2 = maxSumSub(arr,mid+1,e);
int sum =0;
for(int i = h1.x;i<=h2.y;i++){
sum+=arr[i];
}
if(sum>(h1.val) && sum>h2.val){
hold temp;
temp.x = h1.x;
temp.y = h2.y;
temp.val = sum;
return temp;
}
else return h1.val>h2.val?h1:h2;
}
int main() {
int t;
cin >> t;
while(t--){
int n;
cin >> n;
int *arr = new int [n];
for(int i =0 ;i<n;i++){
cin >> arr[i];
}
hold h;
h = maxSumSub(arr,0,n-1);
cout << h.val << endl;
}
return 0;
}