#include <bits/stdc++.h>
const int dx8[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int dy8[] = {0, 0, 1, -1, 1, -1, -1, 1};
const int dx4[] = {1, -1, 0, 0};
const int dy4[] = {0, 0, 1, -1};
using namespace std;
void task() {
  int n;
  cin >> n;
  long long arr[n];
  vector<pair<long long, int>> pos, neg;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  long long best = 0, curr = 0;
  for (int i = n - 1; i >= 0; i--) {
    curr += arr[i];
    best = max(best, curr);
  }
  cout << best << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int TT;
  cin >> TT;
  while (TT--) {
    task();
  }
  return 0;
}
