#include <bits/stdc++.h>
using namespace std;
long long arr[100010];
long long min(long long a, long long b) { return a > b ? b : a; }
int main() {
  int tt;
  cin >> tt;
  while (tt--) {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> arr[i];
    long long res = 0;
    long long curr = 0;
    for (int i = 0; i < n; i++) {
      curr += arr[i];
      res = min(res, curr);
    }
    res = min(res, curr);
    cout << (0 - res) << endl;
  }
}
