#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
bool isprime[N];
void sieve() {
  memset(isprime, 1, sizeof(isprime));
  isprime[0] = isprime[1] = 0;
  for (int i = 2; i <= sqrt(N); i++) {
    if (isprime[i]) {
      for (int j = i * i; j <= N; j += i) {
        isprime[j] = 0;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  sieve();
  int ans[N];
  ans[1] = 1;
  for (int i = 2; i < N; i++) {
    ans[i] = ans[i - 1] + isprime[i];
  }
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int x = sqrt(n);
    cout << ans[n] - ans[x] + 1 << '\n';
  }
  return 0;
}
