#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    long long ans = 0, term = 0, p;
    for (int i = 0; i < n; i++) {
      cin >> p;
      if (term + p <= 0) {
        ans -= (term + p);
        term = 0;
      } else
        term += p;
    }
    cout << ans << endl;
  }
  return 0;
}
