#include <bits/stdc++.h>
using namespace std;
bool st[1000005];
long long int sv[1000006];
void Sieve() {
  long long int sq = sqrt(1000000);
  st[1] = 0;
  for (long long int i = 4; i < 1000000; i += 2) {
    st[i] = 1;
  }
  for (long long int i = 3; i < sq; i += 2) {
    if (st[i] != 1) {
      for (long long int j = i * i; j <= 1000000; j = j + i) st[j] = 1;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  Sieve();
  long long int cn = 0;
  for (long long int i = 1; i <= 1000000; i++) {
    long long int vl;
    vl = sqrt(i);
    if (st[i] == 0) {
      cn += 1;
    } else if (vl * vl == i && st[vl] == 0) {
      cn -= 1;
    }
    sv[i] = cn;
  }
  long long int t, n;
  cin >> t;
  while (t--) {
    cin >> n;
    cout << sv[n] << '\n';
  }
}
