#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
template <typename T, typename T1>
T amax(T &a, T1 b) {
  if (b > a) a = b;
  return a;
}
template <typename T, typename T1>
T amin(T &a, T1 b) {
  if (b < a) a = b;
  return a;
}
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  ll sum = 0;
  ll ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    sum += a[i];
    if (sum > ans) ans = sum;
  }
  cout << ans << endl;
}
int main() {
  ll t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
