#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int t;
  cin >> t;
  while (t--) {
    long long n, balance = 0, output = 0;
    cin >> n;
    vector<long long> v;
    for (long long i = 0; i < n; i++) {
      long long a;
      cin >> a;
      balance += a;
      if (balance < 0) {
        output += (-balance);
        balance = 0;
      }
    }
    cout << output << '\n';
  }
  return 0;
}
