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;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
const int N = 251;
const int P = 1005;
const double e = 2.718281828459045235360287471352;
int a[N];
double tp1[P << 1], tp2[P << 1];
int main() {
  int T = read();
  while (T--) {
    int mx = 0;
    double mean = 0;
    for (int i = 1; i <= 250; i++)
      a[i] = read(), mean += a[i], mx = max(mx, a[i]);
    double D = 0;
    mean /= 250;
    for (int i = 1; i <= 250; i++) D += a[i] * a[i];
    D /= (double)250;
    D -= mean * mean;
    double D1 = mean;
    double D2 = mean * mean / 3.0;
    if (fabs(D - D1) < fabs(D - D2))
      printf("%d\n", (int)mean);
    else
      printf("%d\n", (int)(mx + 1) / 2);
  }
  return 0;
}