#include <bits/stdc++.h>
using namespace std;
bool flags[(int)1e+6 + 1] = {};
int hmap[(int)1e+6 + 1] = {};
void sieve_of_eratosthenes() {
  for (long long i = 2; i <= 1e+6; i++) {
    long long j = i;
    while (i * j <= 1e+6) {
      flags[i * j++] = true;
    }
  }
  for (int i = 2; i <= 1e+6; i++) {
    hmap[i] = hmap[i - 1];
    if (!flags[i]) {
      hmap[i]++;
    }
  }
}
void solution() {
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (int i = 0; i < n; i++) {
    cout << hmap[arr[i]] - hmap[(int)sqrt(arr[i])] + 1 << '\n';
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int count, counter = 0;
  count = 1;
  sieve_of_eratosthenes();
  while (counter++ < count) {
    solution();
  }
  return 0;
}
