#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
int main() {
  long long int testCase;
  cin >> testCase;
  while (testCase--) {
    long long int n;
    cin >> n;
    vector<int> vec(n + 1);
    for (long long int i = 0; i < n; ++i) {
      cin >> vec[i];
    }
    long long int sum = 0;
    long long int ans = 0;
    for (long long int j = 0; j < n; ++j) {
      sum += vec[j];
      ans = min(ans, sum);
    }
    cout << -ans << endl;
  }
  return 0;
}
