#include <bits/stdc++.h>
using namespace std;
const long long SZ = 1e6 + 5;
vector<long long> cnt, res;
vector<bool> prime;
void sieve() {
  cnt.resize(SZ, 0);
  res.resize(SZ);
  res[1] = 1;
  prime.resize(SZ, 1);
  prime[0] = prime[1] = 0;
  long long c = 0;
  for (long long i = 2; i < SZ; ++i) {
    if (prime[i]) {
      ++c;
      if (i * i < SZ) --cnt[i * i];
      for (long long j = i + i; j < SZ; j += i) {
        prime[j] = 0;
      }
    }
    res[i] = res[i - 1];
    if (prime[i])
      ++res[i];
    else
      res[i] += cnt[i];
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  sieve();
  long long n;
  cin >> n;
  for (long long i = 0; i < n; ++i) {
    long long x;
    cin >> x;
    cout << res[x] << '\n';
  }
  return 0;
}
