#include <bits/stdc++.h>
using namespace std;
void err() { cout << "\n"; }
template <class T, class... Ts>
void err(const T& arg, const Ts&... args) {
  cout << arg << ' ';
  err(args...);
}
inline int read() {
  int s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
  return s * w;
}
void run() {
  int n = read();
  long long sum = 0;
  long long ans = 0;
  while (n--) {
    int a = read();
    sum += a;
    ans = ((ans) < (sum) ? (ans) : (sum));
  }
  cout << -ans << "\n";
}
int main() {
  int _T = read();
  while (_T--) run();
  return 0;
}
