#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using namespace std;
const ll inf = 2e18;
const ll mod = 1e9 + 7;
const ll N = 1e6 + 5;
int n, a[N];
vector<int> primes;
void sieve(int n = 1e6) {
  primes = vector<int>(n + 1, 1);
  primes[1] = primes[0] = 0;
  for (int i = 2; i * i <= n; i++) {
    if (primes[i]) {
      for (int j = i * i; j <= n; j += i) {
        primes[j] = 0;
      }
    }
  }
}
void code() {
  sieve();
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int cnt = 0;
  vector<int> prime;
  for (int i = 2; i <= 1e6; i++) {
    if (primes[i]) prime.push_back(i);
  }
  for (int i = 0; i < n; i++) {
    auto it = upper_bound((prime).begin(), (prime).end(), a[i]);
    it--;
    int idx1 = it - prime.begin();
    int x = sqrt(a[i]);
    auto it2 = upper_bound((prime).begin(), (prime).end(), x);
    it2--;
    int idx2 = it2 - prime.begin();
    cout << idx1 - idx2 + 1 << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int t = 1;
  while (t-- > 0) {
    code();
  }
}
