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 N = 250;
int a[N];
int P;
int read() {
  int x;
  scanf("%d", &x);
  return x;
}
void solve() {
  double s = 0, s2 = 0;
  for (int i = 0; i < N; i++) {
    int x = read();
    a[i] = x;
    s += x;
    s2 += (double)x * x;
  }
  s /= N;
  s2 /= N;
  double y = s2 / s / s;
  if (y > 1.15) {
    int m = 0;
    for (int i = 0; i < N; i++) m = max(m, a[i]);
    int ans = m;
    while ((ans + 1) / 1.045 < m) ans++;
    printf("%d\n", ans / 2);
  } else {
    printf("%d\n", (int)(s + 0.5));
  }
  return;
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) solve();
  return 0;
}