#include <bits/stdc++.h>
inline void setIO();
using namespace std;
void solve() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  long long cost = 0;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    if (sum + a[i] < 0) {
      cost += abs(a[i] + sum);
      sum = 0;
    } else {
      sum += a[i];
    }
  }
  cout << cost << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
inline void setIO(string name = "") {}
