#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> arr(n, 0);
    for (auto &i : arr) cin >> i;
    sort(arr.begin(), arr.end());
    int pos = count_if(arr.begin(), arr.end(), [](int x) {
      if (x > 0)
        return true;
      else
        return false;
    });
    int neg = count_if(arr.begin(), arr.end(), [](int x) {
      if (x < 0)
        return true;
      else
        return false;
    });
    cout << arr[n - 1] << endl;
  }
  return 0;
}
