#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int nax = 1e6 + 10;
bool notprime[nax - 1];
vector<int> countNumPrime(nax - 1, 0);
void sumPrime() {
  countNumPrime[1] = 0;
  for (int i = 2; i <= nax; i++) {
    countNumPrime[i] = countNumPrime[i - 1] + (!notprime[i]);
  }
}
void seive() {
  for (int i = 2; i <= nax; i++) {
    if (notprime[i] == 0) {
      for (int j = i * 2; j <= nax; j += i) {
        notprime[j] = 1;
      }
    }
  }
}
void solve() {
  ll n;
  cin >> n;
  ll s = sqrt(n);
  cout << countNumPrime[n] - countNumPrime[s] + 1;
}
int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);
  seive();
  sumPrime();
  int TEST_CASE = 1;
  cin >> TEST_CASE;
  while (TEST_CASE--) {
    solve();
    cout << "\n";
  }
  cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
  return 0;
}
