#include <bits/stdc++.h>
#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que;
const double EPS = 1.0e-8;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
const int maxn = 1e5 + ;
const int maxm = ;
//next_permutation
priority_queue<int, vector<int>, greater<int>> que;
int number[];
int dp[];
int main()
{
//freopen("in.txt", "r", stdin);
int time ;
cin >> time;
while(time--)
{
int maxn=-;
dp[]=;
int n;
cin >> n;
for(int i=;i<=n;i++)
{
cin >>number[i];
dp[i]=dp[i-]+number[i];
maxn=max(maxn,dp[i]);
if(dp[i]<)
dp[i]=;
}
cout<<maxn<<endl;
}
}