Problem: Good job! Now that Heidi is able to distinguish between Poisson and uniform distributions, she is in a good position to actually estimate the populations.

Can you help Heidi estimate each village's population?

Input

Same as the easy version.

Output

Output one line per village, in the same order as provided in the input, containing your (integer) population estimate.

Your answer is considered correct if it is an integer that falls into the interval <image>, where P is the real population of the village, used to create the distribution (either Poisson or uniform) from which the marmots drew their answers.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
template <class A, class B>
ostream& operator<<(ostream& out, const pair<A, B>& a) {
  return out << "(" << a.first << ", " << a.second << ")";
}
template <class A>
ostream& operator<<(ostream& out, const vector<A>& v) {
  out << "[";
  for (int i = 0; i < int(int(v.size())); i++) {
    if (i) out << ", ";
    out << v[i];
  }
  return out << "]";
}
mt19937 rnd(time(NULL));
const int INF = int(1e9);
const long long INF64 = long long(1e18);
const int MOD = INF + 7;
const long double EPS = 1e-9;
const long double PI = acos(-1.0);
const int N = 500;
int n = 250;
int a[N];
int rp;
bool read() {
  for (int i = 0; i < int(n); i++) scanf("%d", &a[i]);
  return true;
}
void solve() {
  sort(a, a + n);
  long double med = 0;
  for (int i = 0; i < int(n); i++) med += a[i];
  med /= n;
  long double sum = 0;
  for (int i = 0; i < int(n); i++) sum += ((a[i]) * (a[i]));
  long double d = sum / n - ((med) * (med));
  long double uni = ((med) * (med)) / long double(3);
  long double poi = med;
  if (fabsl(uni - d) < fabsl(poi - d)) {
    med = (a[n - 1] + 1) / 2;
  }
  printf("%d\n", int(med));
}
int main() {
  cerr.precision(5);
  cout.precision(15);
  cerr << fixed;
  cout << fixed;
  int tc;
  scanf("%d", &tc);
  while (tc--) {
    read();
    solve();
  }
}