#include <bits/stdc++.h>
using namespace std;
using ll = long long;
long long int mod_pow(long long int a, long long int b, long long int m) {
  long long int res = 1;
  while (b) {
    if (b & 1) {
      res = (res * a) % m;
    }
    a = (a * a) % m;
    b >>= 1;
  }
  return res;
}
long long int mod_inverse(long long int a, long long int m) {
  return mod_pow(a, m - 2, m);
}
const long long int mx = 1e6 + 5;
vector<long long int> d;
long long int vis[mx];
long long int ans[mx];
void go() {
  for (long long int i = 2; i < mx; ++i) {
    if (vis[i] == 0) {
      d.push_back(i);
      for (long long int j = 2 * i; j < mx; j += i) {
        vis[j] = 1;
      }
    }
  }
}
void pre() {
  long long int t1 = 0;
  long long int t2 = 0;
  for (long long int i = 1; i < mx; ++i) {
    long long int now = sqrt(i) + 1;
    while (t1 < d.size() && d[t1] <= i) {
      t1++;
    }
    while (t2 < d.size() && d[t2] < now) {
      t2++;
    }
    ans[i] = t1 - t2 + 1;
  }
}
void solve() {
  long long int n;
  cin >> n;
  cout << ans[n] << "\n";
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int t = 1;
  go();
  pre();
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
