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;
const int Imx = 2147483647;
const int mod = 1000000007;
const long long Lbig = 2e18;
inline long long getnum() {
  register long long r = 0;
  register bool ng = 0;
  register char c;
  c = getchar();
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  if (c == '-') ng = 1, c = getchar();
  while (c >= '0' && c <= '9') r = r * 10 + c - '0', c = getchar();
  if (ng) r = -r;
  return r;
}
template <class T>
inline void putnum(T x) {
  if (x < 0) putchar('-'), x = -x;
  register short a[20] = {}, sz = 0;
  while (x > 0) a[sz++] = x % 10, x /= 10;
  if (sz == 0) putchar('0');
  for (int i = sz - 1; i >= 0; i--) putchar('0' + a[i]);
}
inline void putsp() { putchar(' '); }
inline void putendl() { putchar('\n'); }
inline char mygetchar() {
  register char c = getchar();
  while (c == ' ' || c == '\n') c = getchar();
  return c;
}
int Tn;
double a[255], ia[255];
int cnt[1011];
void solve() {
  memset(cnt, 0, sizeof(cnt));
  double mn = 0, mx = 0;
  for (int i = 1; i <= 250; i++) {
    a[i] = getnum();
    ia[i] = a[i];
    mn = min(mn, a[i]);
    mx = max(mx, a[i]);
  }
  for (int i = 1; i <= 250; i++) a[i] = 1.0 * a[i] / mx;
  double av = 0, sum = 0;
  for (int i = 1; i <= 250; i++) av += a[i];
  av /= 250;
  for (int i = 1; i <= 250; i++)
    sum += (a[i] - av) * (a[i] - av) * (a[i] - av) * (a[i] - av);
  if (sum < 1.8) {
    sort(ia + 1, ia + 251);
    cout << int((ia[125] + ia[126]) / 2) << endl;
  } else {
    cout << int(mx / 2.0) << endl;
  }
}
int main() {
  Tn = getnum();
  while (Tn--) {
    solve();
  }
  return 0;
}