#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    vector<long long int> v(n);
    for (long long int i = 0; i < n; i++) {
      cin >> v[i];
    }
    long long int curr = 0;
    for (long long int i = 0; i < n; i++) {
      if (v[i] >= 0) {
        curr += v[i];
      } else {
        long long int p = 0;
        curr = max(p, curr + v[i]);
      }
    }
    cout << curr << endl;
  }
}
