#include <bits/stdc++.h>
using namespace std;
int const INF = 1e9 + 7;
long long IN = 1e14;
int n, m, k, l, r, t, qq, an;
string s, s1, s2;
multimap<int, int> ma, ma1;
set<int> se, se1;
char ch;
vector<int> v, v1;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> qq;
  while (qq--) {
    an = 0;
    t = 0;
    k = 0;
    long long a = 0, b = 0, x, y, ans = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> x;
      a += x;
      if (a < 0) {
        b += a;
        a = 0;
      }
    }
    cout << a << endl;
  }
  return 0;
}
