#include <bits/stdc++.h>
using namespace std;
vector<int> pr;
vector<bool> used(1000001, false);
vector<int> d(1000001, 0);
void sieve() {
  for (long long i = 2; i <= 1000000; i++) {
    for (long long k = i * i; k <= 1000000; k += i) used[k] = true;
  }
  for (int i = 2; i <= 1000000; i++)
    if (!used[i]) pr.push_back(i);
}
int main() {
  sieve();
  d[1] = 1;
  for (int i = 2; i <= 1000000; i++) {
    d[i] = d[i - 1];
    int k = lower_bound(pr.begin(), pr.end(), i) - pr.begin();
    int k1 = upper_bound(pr.begin(), pr.end(), i) - pr.begin();
    if (k1 - k > 0) {
      d[i]++;
      continue;
    }
    int x = sqrt(i);
    if (x * x == i) {
      k = lower_bound(pr.begin(), pr.end(), x) - pr.begin();
      k1 = upper_bound(pr.begin(), pr.end(), x) - pr.begin();
      if (k1 - k > 0) {
        d[i]--;
      }
    }
  }
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d", &n);
    printf("%d\n", d[n]);
  }
  return 0;
}
