#include <bits/stdc++.h>
using namespace std;
const long long mod = (long long)1e9 + 7;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    vector<long long> a(n);
    for (auto &i : a) cin >> i;
    long long ls = 0, ans = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] > 0)
        ls += a[i];
      else {
        ls += a[i];
        ans += min(ls, 0ll);
        ls = max(ls, 0ll);
      }
    }
    cout << abs(ls) << "\n";
  }
  return 0;
}
