#include <bits/stdc++.h>
using namespace std;
int cnt[1000005];
bool status[1000005];
int main() {
  for (int i = 2; i * i <= 1000000; i++) {
    if (!status[i]) {
      for (int j = i * i; j <= 1000000; j += i) {
        status[j] = true;
      }
    }
  }
  for (int i = 1; i <= 1000000; i++) {
    cnt[i] = cnt[i - 1];
    if (!status[i]) {
      cnt[i]++;
    }
  }
  int n;
  scanf("%d", &n);
  int x, y;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    y = sqrt(x);
    cout << cnt[x] - cnt[y] + 1 << '\n';
  }
  return 0;
}
