#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const long long int inf = 4294967295;
void dk_98() {}
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long power(long long x, long long y) {
  long long res = 1;
  x = x % mod;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % mod;
    y = y >> 1;
    x = (x * x) % mod;
  }
  return res;
}
vector<pair<long long, long long>> tree;
bool prime[1000001];
vector<pair<long long, long long>> primesq;
void SieveOfEratosthenes(int n) {
  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;
    }
  }
  for (long long i = 2; i <= 1000000; i++) {
    if (prime[i]) primesq.push_back({i, i * i});
  }
}
void solve() {
  int n;
  cin >> n;
  while (n--) {
    long long k;
    cin >> k;
    pair<long long, long long> p1 = {k, 1e12};
    int ub1 = upper_bound(primesq.begin(), primesq.end(), p1) - primesq.begin();
    pair<long long, long long> p2 = {(int)sqrt(k), k};
    int ub2 = upper_bound(primesq.begin(), primesq.end(), p2) - primesq.begin();
    ub2--;
    cout << ub1 - ub2 << '\n';
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  dk_98();
  SieveOfEratosthenes(1000000);
  int t = 1;
  for (int i = 1; i <= (int)(t); i++) {
    solve();
    cout << '\n';
  }
}
