#include <bits/stdc++.h>
using namespace std;
long long n;
bool ok(long long x) {
  long long h = (x + 1) / 2;
  long long reste = x - h;
  long long restv = n - h;
  if (restv < 0) return false;
  long long perf = restv * (restv - 1) / 2;
  return reste <= perf;
}
int main() {
  cin.sync_with_stdio(false);
  int q;
  cin >> q;
  while (q--) {
    cin >> n;
    if (n == 1) {
      cout << 0 << endl;
      continue;
    }
    long long lb = 0, ub = 2e18;
    while (ub - lb > 1) {
      long long mid = (ub + lb) / 2;
      if (ok(mid))
        lb = mid;
      else
        ub = mid;
    }
    cout << lb << endl;
  }
  return 0;
}
