#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int t;
  cin >> t;
  for (int i1 = 0; i1 < t; ++i1) {
    int n;
    cin >> n;
    int64_t mins = 0, sum = 0;
    for (int i = 0; i < n; ++i) {
      int64_t ai;
      cin >> ai;
      sum += ai;
      if (sum < mins) mins = sum;
    }
    cout << -mins << '\n';
  }
  return 0;
}
