#include <bits/stdc++.h>
using namespace std;
const long long INF = 2e18;
const long long MAX = 1000002;
long long prime[MAX + 1];
long long ans[MAX];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long i;
  for (i = 0; i < MAX; i++) {
    prime[i] = 1;
    ans[i] = 0;
  }
  for (i = 2; i * i < MAX; i++) {
    if (prime[i]) {
      for (long long j = i * i; j < MAX; j += i) {
        prime[j] = 0;
      }
    }
  }
  for (i = 2; i < MAX; i++) {
    if (prime[i] == 1 && i * i < MAX) {
      prime[i * i] = -1;
    }
  }
  prime[1] = 1;
  for (i = 1; i < MAX; i++) {
    ans[i] = ans[i - 1] + prime[i];
  }
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    cout << ans[n] << "\n";
  }
  return 0;
}
