#include <bits/stdc++.h>
using namespace std;
long long ch_sqrt(long long n) { return (sqrt(n) * sqrt(n) == n) ? 1 : 0; }
long long pow_(long long a, long long b, long long m) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  vector<long long> p(1e7 + 3, 1), pr;
  p[0] = p[1] = 0;
  for (long long i = 2; i < p.size(); i++) {
    if (p[i]) {
      for (long long j = i * i; j < p.size(); j += i) {
        p[j] = 0;
      }
    }
    if (p[i]) pr.push_back(i);
  }
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    if (n == 1) {
      cout << n << "\n";
      continue;
    }
    long long s = sqrt(n);
    auto it = upper_bound(pr.begin(), pr.end(), s);
    auto iit = upper_bound(pr.begin(), pr.end(), n);
    cout << iit - pr.begin() - (it - pr.begin()) + 1 << "\n";
  }
  return 0;
}
