#include <bits/stdc++.h>
using namespace std;
void solution() {
  int n;
  cin >> n;
  int arr[n];
  long long ops = 0, status = 0;
  for (int i = 0; i < n; i++) {
    int current;
    cin >> current;
    status += current;
    if (status < 0) {
      ops += -status;
      status = 0;
    }
  }
  cout << ops << endl;
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long count, counter = 0;
  cin >> count;
  while (counter++ < count) {
    solution();
  }
  return 0;
}
