#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  scanf("%d", &t);
  vector<bool> isprime(1e6 + 1, true);
  isprime[1] = false;
  for (int i = 2; i * i <= 1e6; i++) {
    if (isprime[i]) {
      for (int j = i * i; j <= 1e6; j += i) {
        isprime[j] = false;
      }
    }
  }
  int primes[1000001];
  primes[0] = primes[1] = 0;
  for (int i = 2; i <= 1e6; i++) {
    primes[i] = primes[i - 1] + (isprime[i]);
  }
  while (t--) {
    int n;
    scanf("%d", &n);
    int x = floor(sqrt(n));
    printf("%d\n", primes[n] - primes[x] + 1);
  }
  return 0;
}
