#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;
      }
    }
  }
  for (long long i = 2; i <= n; i++) {
    if (!vis[i]) primes.push_back(i);
  }
}
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() {
  vector<long long> Prime;
  long long i, j;
  bool visited[1000005];
  for (i = 1; i <= 1000000; i++) visited[i] = true;
  for (i = 2; i <= 1000000; i++) {
    if (!visited[i]) continue;
    Prime.push_back(i);
    for (j = i; j <= 1000000; j += i) {
      visited[j] = false;
    }
  }
  long long n;
  cin >> n;
  vector<pair<long long, long long> > Query;
  for (i = 0; i < n; i++) {
    long long num;
    cin >> num;
    Query.push_back({num, i});
  }
  sort(Query.begin(), Query.end());
  long long Ans[n];
  long long prevtp = 0, prevpp = 0;
  for (i = 0; i < n; i++) {
    long long low = 0, high = (long long)Prime.size() - 1;
    long long tp = 0;
    long long num = Query[i].first;
    while (low <= high) {
      long long mid = (low + high) / 2;
      if (Prime[mid] <= num) {
        tp = mid + 1;
        low = mid + 1;
      } else {
        high = mid - 1;
      }
    }
    prevtp = tp;
    long long pp = 0;
    low = 0, high = tp - 1;
    while (low <= high) {
      long long mid = (low + high) / 2;
      if (Prime[mid] * Prime[mid] <= num) {
        pp = mid + 1;
        low = mid + 1;
      } else {
        high = mid - 1;
      }
    }
    prevpp = pp;
    Ans[Query[i].second] = tp - pp + 1;
  }
  for (i = 0; i < n; i++) cout << Ans[i] << " ";
  cout << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  sieve(1000001);
  long long t = 1;
  cout << "\n";
  while (t--) {
    solve();
  }
  return 0;
}
