#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
bool vis[N];
vector<int> prime;
void sieve() {
  for (int i = 2; i * i < N; i++) {
    if (vis[i]) continue;
    for (int j = 2; j * i < N; j++) {
      vis[i * j] = 1;
    }
  }
  for (int i = 2; i < N; i++) {
    if (vis[i] == 0) prime.push_back(i);
  }
}
int find(int x) {
  int ans = upper_bound(prime.begin(), prime.end(), x) - prime.begin() - 1;
  return ans;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  sieve();
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int ans = find(n) - find(sqrt(n)) + 1;
    cout << ans << "\n";
  }
  return 0;
}
