#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using dl = double;
using ull = unsigned long long;
const int N = 1e6 + 6;
ll aarray[1000200];
bool ok[1000200];
void seive() {
  ll i, j;
  ll jabe = sqrt(1000000);
  for (i = 4; i < 1000000; i += 2) {
    ok[i] = 1;
  }
  for (i = 3; i < jabe; i += 2) {
    if (ok[i] == 0) {
      for (j = i * i; j <= 1000000; j += i) {
        ok[j] = 1;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  seive();
  ll p = 0;
  for (ll i = 1; i <= 1000000; i++) {
    ll k;
    k = sqrt(i);
    if (!ok[i]) {
      p += 1;
    } else if (k * k == i && !ok[k]) {
      p -= 1;
    }
    aarray[i] = p;
  }
  ll n, t;
  cin >> t;
  while (t--) {
    cin >> n;
    cout << aarray[n] << "\n";
  }
  return 0;
}
