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>
#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
int IT_MAX = 1 << 19;
const long long MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const long long LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1E-11;
const int MX = 100005;
void make(int P, int A[]) {
  for (int i = 0; i < 250; i++) {
    A[i] = rand() % (2 * P + 1);
  }
}
void Do() {
  int A[255] = {};
  for (int i = 0; i < 250; i++) scanf("%d", A + i);
  double avg = 0;
  for (int i = 0; i < 250; i++) avg += A[i];
  avg /= 250.0;
  int cnt = 0;
  for (int i = 0; i < 250; i++) {
    double X = (double)A[i] / avg;
    if (0.5 <= X && X <= 1.5) ++cnt;
  }
  double C = cnt / 250.0;
  if (C > 0.7) {
    printf("%d\n", (int)(avg + 0.5));
  } else {
    int t = *max_element(A, A + 250);
    printf("%d\n", t / 2);
  }
}
int main() {
  int V;
  scanf("%d", &V);
  while (V--) {
    Do();
  }
  return 0;
}