#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 5;
bool prime[N];
long long cnt[N];
void pre() {
  for (long long i = 0; i < N; i++) prime[i] = true;
  prime[0] = false;
  for (long long i = 2; i * i < N; i++) {
    for (long long j = i * i; j < N; j += i) prime[j] = false;
  }
  for (long long i = 2; i < N; i++) {
    if (prime[i]) {
      cnt[i]++;
      long long x = min(N - 1, i * i);
      cnt[x]--;
    }
  }
  for (long long i = 1; i < N; i++) {
    cnt[i] += cnt[i - 1];
    cnt[i - 1]++;
  }
}
void run_case() {
  long long n;
  cin >> n;
  cout << cnt[n] << '\n';
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  pre();
  long long T = 1;
  cin >> T;
  while (T--) {
    run_case();
  }
  return 0;
}
