#include <bits/stdc++.h>
using namespace std;
const long long int N = 1e6 + 1;
long long int arr[N];
bool prime[N];
void Sieve() {
  arr[1] = 1;
  for (long long int i = 2; i <= N; i++) {
    arr[i] += arr[i - 1];
    if (prime[i]) {
      arr[i]++;
      if (i < 1000) arr[(i * i)] -= 1;
      for (long long int j = i * 2; j <= N; j += i) {
        prime[j] = false;
      }
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  for (long long int i = 0; i <= 1e6; i++) {
    prime[i] = true;
  }
  Sieve();
  arr[0] = 0;
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    cout << arr[n] << '\n';
  }
  return 0;
}
