#include <bits/stdc++.h>
using namespace std;
long long int power(long long int a, long long int b) {
  long long int res = 1;
  a = a % 1000000007;
  while (b > 0) {
    if (b & 1) {
      res = (res * a) % 1000000007;
      b--;
    }
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return res;
}
long long int gcd(long long int a, long long int b) {
  return (b == 0) ? a : gcd(b, a % b);
}
vector<long long int> prime(1000006, 0);
vector<long long int> primes;
void sieve() {
  for (long long int i = 2; i < 1000006; i++) {
    if (prime[i] == 0) {
      primes.push_back(i);
      for (long long int j = i; j < 1000006; j += i) {
        if (prime[j] == 0) prime[j] = i;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  sieve();
  long long int t;
  cin >> t;
  vector<long long int> ans(1000003, 0);
  ans[1] = 1;
  for (long long int i = 2; i <= 1000000; i++) {
    if (prime[i] == i) {
      ans[i]++;
      ans[min(i * i, 1000002LL)]--;
    }
    ans[i] += ans[i - 1];
  }
  while (t--) {
    long long int n;
    cin >> n;
    cout << ans[n] << "\n";
  }
}
