#include <bits/stdc++.h>
using namespace std;
const double PI = atan(1) * 4;
const int mod = 1e9 + 7;
int dp[100009];
vector<int> v;
map<int, int> m;
int bore(int n) {
  if (n <= 0) return 0;
  if (dp[n]) return dp[n];
  return dp[n] = max(bore(n - 1), bore(n - 2) + v[n - 1] * m[v[n - 1]]);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int tt = 1;
  cin >> tt;
  while (tt--) {
    int n;
    cin >> n;
    int a[n];
    for (int i = int(0); i < int(n); ++i) cin >> a[i];
    long long sum = 0, ans = 0;
    for (int i = int(0); i < int(n); ++i) {
      sum += a[i];
      ans = min(ans, sum);
    }
    cout << -ans << "\n";
  }
  cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
  return 0;
}
