#include <bits/stdc++.h>
using namespace std;
long long n;
long long getleast(long long m) {
  long long lo = 0, hi = 1e7, mi, found;
  while (lo <= hi) {
    mi = (lo + hi) / 2;
    if ((mi * (mi - 1)) / 2 - max(0LL, mi - 1) >= m) {
      found = mi;
      hi = mi - 1;
    } else
      lo = mi + 1;
  }
  return found;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int q;
  cin >> q;
  long long b;
  for (int i = 0; i < q; i++) {
    cin >> n;
    long long lo = n - 1, hi = 2 * n - 2, found = -1, m;
    while (lo <= hi) {
      m = (lo + hi) / 2;
      b = getleast(m - n + 1);
      if ((n - b) * 2 >= m) {
        found = m;
        lo = m + 1;
      } else
        hi = m - 1;
    }
    if (found == -1)
      cout << n - 1 << '\n';
    else
      cout << found << '\n';
  }
  return 0;
}
