#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 100;
int vis[N];
int p[N];
int sum[N];
int main() {
  int t = 0;
  for (int i = 2; i <= 1000010; i++) {
    if (vis[i] == 0) p[++t] = i;
    for (int j = 1; j <= t && (i * p[j] <= 1000010); j++) {
      vis[i * p[j]] = 1;
      if (i % p[j] == 0) {
        break;
      }
    }
  }
  for (int i = 1; i <= 1000010; i++) {
    if (vis[i] == 0) {
      sum[i] = 1 + sum[i - 1];
    } else {
      sum[i] = sum[i - 1];
    }
  }
  int k;
  scanf("%d", &k);
  while (k--) {
    double n;
    scanf("%lf", &n);
    int q = (int)n;
    int w = (int)sqrt(n);
    printf("%d\n", sum[q] - sum[w] + 1);
  }
  return 0;
}
