#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
long long ii = 1;
vector<long long> prime;
bitset<1000000> bs;
void sieve() {
  bs.set();
  bs[0] = bs[1] = 0;
  prime.push_back(2);
  for (long long i = 3; i <= 1000000; i += 2) {
    if (bs[i]) {
      for (long long j = i * i; j <= 1000000; j += i) bs[j] = 0;
      prime.push_back(i);
    }
  }
}
void solve() {
  long long n;
  cin >> n;
  long long l = 0;
  long long r = prime.size() - 1;
  long long p = sqrt(n);
  while (l <= r) {
    long long mid = (l + r) / 2;
    if (prime[mid] <= p)
      l = mid + 1;
    else
      r = mid - 1;
  }
  long long cn = l - 1;
  l = 0;
  r = prime.size() - 1;
  while (l <= r) {
    long long mid = (l + r) / 2;
    if (prime[mid] <= n)
      l = mid + 1;
    else
      r = mid - 1;
  }
  cout << r - cn + 1 << '\n';
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long TestCase;
  sieve();
  cin >> TestCase;
  while (TestCase--) solve();
  return 0;
}
