#include <bits/stdc++.h>
std::mt19937_64 rng(
    std::chrono::steady_clock::now().time_since_epoch().count());
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  long long nax = 1e6 + 5;
  vector<long long> sieve(nax, 0);
  long long x, y, z;
  for (long long i = 2; i < nax; i++) {
    if (sieve[i]) continue;
    for (long long j = 2 * i; j < nax; j += i) {
      sieve[j] = 1;
    }
  }
  sieve[1] = 1;
  for (long long i = 1; i < nax; i++) {
    sieve[i] ^= 1;
    sieve[i] += sieve[i - 1];
  }
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long tmp = sqrt(n);
    cout << sieve[n] - sieve[tmp] + 1 << '\n';
  }
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}
