#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
vector<long long> primes;
vector<long long> vis(1000001, 0);
vector<long long> v(1000001, 0);
void sieve(long long n) {
  primes.clear();
  vis.clear();
  for (long long i = 2; i * i <= n; i++) {
    if (!vis[i]) {
      for (long long j = i * i; j <= n; j += i) {
        vis[j] = 1;
      }
    }
  }
}
long long factorize(long long n) {
  long long cnt = 0;
  for (auto x : primes) {
    if (n < x) break;
    while (n % x == 0) {
      n = n / x;
      cnt++;
    }
  }
  if (n > 1) cnt++;
  return cnt;
}
bool compare(pair<long long, long long> a, pair<long long, long long> b) {
  return a.second < b.second;
}
void remove_duplicates(vector<long long> &v) {
  long long i = 0;
  while (i < v.size() - 1) {
    if (v[i] == v[i + 1])
      v.erase(v.begin() + i, v.begin() + i + 1);
    else
      i++;
  }
  return;
}
unordered_map<long long, unordered_map<long long, long long> > ncrmap;
long long nCr(long long n, long long r) {
  if (ncrmap[n].find(ncrmap[n][r]) == ncrmap[n].end()) {
    if (n < r) return ncrmap[n][r] = 0;
    if (n == r) return ncrmap[n][r] = 1;
    if (r == 1) return ncrmap[n][r] = n;
    if (r == 0) return ncrmap[n][r] = 1;
    ncrmap[n][r] = nCr(n - 1, r - 1) + nCr(n - 1, r);
  }
  return ncrmap[n][r];
}
void solve() {
  long long x;
  cin >> x;
  cout << (v[x] - v[sqrt(x)]) + 1 << " ";
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  sieve(1000001);
  vis[1] = 0;
  v[1] = 0;
  for (long long i = 2; i < 1000001; i++) {
    v[i] = v[i - 1] + (vis[i] == 0 ? 1 : 0);
  }
  long long t = 1;
  cin >> t;
  cout << endl;
  while (t--) {
    solve();
  }
  return 0;
}
