#include <bits/stdc++.h>
long long get_more(long long bridges, long long edges, long long lim) {
  long long low = 0, high = lim;
  while ((low + 1) < high) {
    long long mid = (low + high) >> 1;
    if ((2 * bridges) >= (mid + edges))
      low = mid;
    else
      high = mid;
  }
  if ((2 * bridges) >= (high + edges)) return high + edges;
  if ((2 * bridges) >= (low + edges)) return low + edges;
  return -1;
}
long long check(long long n, long long lim) {
  long long bridges = n - lim;
  long long edges = (n - 1) + (((lim - 3) * (lim - 2)) / 2);
  return get_more(bridges, edges, lim - 2);
}
long long solve(long long n) {
  if (n == 0) return 0;
  if (n <= 8) return n - (n <= 5);
  long long low = 4, high = n, mid = 0, res = n - 1;
  while ((low + 5) < high) {
    mid = (low + high) >> 1;
    if (check(n, mid) != -1)
      low = mid;
    else
      high = mid;
  }
  for (mid = low; mid <= high; mid++) {
    long long x = check(n, mid);
    if (x > res) res = x;
  }
  return res;
}
int main() {
  int q, n;
  scanf("%d", &q);
  while (q--) {
    scanf("%d", &n);
    printf("%lld\n", solve(n));
  }
  return 0;
}
