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 T>
int getbit(T s, int i) {
  return (s >> i) & 1;
}
template <class T>
T onbit(T s, int i) {
  return s | (T(1) << i);
}
template <class T>
T offbit(T s, int i) {
  return s & (~(T(1) << i));
}
template <class T>
int cntbit(T s) {
  return __builtin_popcnt(s);
}
template <class T>
T gcd(T a, T b) {
  T r;
  while (b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
string s, temp;
int test;
double a[5005];
double sqr(double x) { return x * x; }
int cal(double ave) {
  int res = (int)(ave);
  if (ave - res > 0.5) res++;
  return res;
}
void solve() {
  double sum = 0;
  int n = 250;
  for (int i = (1); i <= (n); ++i) {
    cin >> a[i];
  }
  sort(a + 1, a + n + 1);
  int RRR = (int)((a[1] + a[n]) / 2);
  for (int i = (1); i <= (240); ++i) a[i] = a[i + 5];
  for (int i = (1); i <= (240); ++i) {
    sum += a[i];
  }
  n = 240;
  double ave = sum / n;
  double RR = 0;
  for (int i = (1); i <= (n); ++i) {
    RR += sqr(a[i] - ave);
  }
  RR /= n;
  RR = sqrt(RR);
  if (RR > ave / 3) {
    cout << RRR << endl;
  } else {
    cout << cal(ave) << endl;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> test;
  for (int itest = 0; itest < (test); ++itest) {
    solve();
  }
  return 0;
}