#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1, -1, -1, 0, 1, -1, 0, 1};
const int M = 1000005;
vector<int> divs[M];
int vis[M], dp[M];
void seive() {
  for (int i = 2; i < M; i++) {
    if (vis[i]) continue;
    for (int j = i + i; j < M; j += i) {
      vis[j] = 1;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  seive();
  for (long long i = 2; i < M; i++) {
    if (vis[i])
      dp[i] += 1;
    else {
      if (i * i < M) dp[i * i]++;
    }
    dp[i] += dp[i - 1];
  }
  int t, tt = 1;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    cout << n - dp[n] << "\n";
  }
  return 0;
}
