#include <bits/stdc++.h>
long long int M = 1000000007;
using namespace std;
vector<int> cnt(1e6 + 1);
void SieveOfEratosthenes(int n) {
  bool prime[n + 1];
  memset(prime, true, sizeof(prime));
  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
  int c = 0;
  cnt[1] = c;
  cnt[0] = c;
  for (int p = 2; p <= n; p++)
    if (prime[p])
      cnt[p] = ++c;
    else
      cnt[p] = c;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << setprecision(25);
  ;
  SieveOfEratosthenes(1e6 + 1);
  int T;
  cin >> T;
  while (T--) {
    int n;
    cin >> n;
    int r = floor(sqrt(n));
    cout << 1 + cnt[n] - cnt[r] << "\n";
  }
  return 0;
}
