#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long a[n], b[n];
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
    }
    b[n - 1] = a[n - 1];
    for (long long i = n - 2; i >= 0; i--) {
      b[i] = b[i + 1] + a[i];
    }
    sort(b, b + n);
    cout << b[n - 1] << "\n";
  }
  return 0;
}
