#include <bits/stdc++.h>
using namespace std;
long long int q, n;
long long int sum, ans;
long long int powe(long long int a, long long int b) {
  long long int res = 1;
  while (b > 0) {
    if (b % 2 == 1) {
      res = (res * a);
    }
    a = (a * a);
    b /= 2;
  }
  return res;
}
long long int power(long long int a, long long int b, long long int M) {
  a %= M;
  long long int res = 1;
  while (b > 0) {
    if (b % 2 == 1) {
      res = (res * a) % M;
    }
    a = (a * a) % M;
    b /= 2;
  }
  return res;
}
long long int extendedEuclid(long long int A, long long int B, long long int &x,
                             long long int &y) {
  if (B == 0) {
    x = 1;
    y = 0;
    return A;
  } else {
    long long int x1, y1;
    long long int gcd = extendedEuclid(B, A % B, x1, y1);
    y = x1 - (A / B) * y1;
    x = y1;
    return gcd;
  }
}
long long int mi(long long int A, long long int M) {
  long long int x, y;
  extendedEuclid(A, M, x, y);
  if (x < 0) {
    x += M;
  }
  return x;
}
vector<bool> sieve(1000020, true);
void Sieve() {
  sieve[0] = false;
  sieve[1] = false;
  for (long long int i = 2; i * i <= 1000020; i++) {
    if (sieve[i] == true) {
      for (long long int j = i * i; j < 1000020; j += i) sieve[j] = false;
    }
  }
}
long long int sieve_spf[1000010];
long long int n1 = 1000000;
void Sieve_spf() {
  for (int i = 0; i < n1; i++) sieve_spf[i] = i;
  sieve_spf[0] = -1;
  sieve_spf[1] = 1;
  for (int i = 2; i < n1; i += 2) sieve_spf[i] = 2;
  for (long long int i = 3; i < n1; i += 2) {
    if (sieve_spf[i] == i) {
      for (long long int j = (i * i); j < n1; j += i) {
        if (sieve_spf[j] == j) sieve_spf[j] = i;
      }
    }
  }
}
const int nax = 3e5 + 5;
long long int fact[nax];
void F() {
  fact[0] = 1;
  for (int i = 1; i < nax; i++) {
    fact[i] = fact[i - 1] * i % (long long int)1000000007;
  }
}
long long int nCr(long long int n, long long int r, long long int M) {
  if (n < r) return 0;
  return (((fact[n] * mi(fact[r], M)) % M) * mi(fact[n - r] % M, M)) % M;
}
void the_happiest_place_on_earth() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
}
bool comp(const pair<long long int, long long int> &a,
          const pair<long long int, long long int> &b) {
  return (a.first < b.first || a.first == b.first && a.second < b.second);
}
const int N = 300055;
long long int a[N], b[N], c[N], p[N], par[N], Size[N], present[N], color[N];
vector<int> adj[N];
int get(int a) { return par[a] = (a == par[a]) ? a : get(par[a]); }
void Union(int a, int b) {
  a = get(a);
  b = get(b);
  if (a != b) {
    if (a > b) swap(a, b);
    Size[a] += Size[b];
    par[b] = a;
  }
}
bool vis[N];
bool val[N];
int root, first, f1;
void dfs(int node) {
  vis[node] = true;
  for (int x : adj[node]) {
    if (!vis[x]) {
      dfs(x);
      if (node != root && color[node] != color[x]) {
        first = 1;
        return;
      }
    }
  }
}
long long int dp[1000020];
void testcase() {
  cin >> n;
  int n1 = sqrt(n);
  cout << dp[n] - dp[n1] + 1;
  cout << "\n";
  return;
}
int main() {
  the_happiest_place_on_earth();
  the_happiest_place_on_earth();
  Sieve();
  dp[1] = 1;
  for (int i = 2; i <= 1000020; i++) {
    dp[i] = dp[i - 1];
    if (sieve[i]) dp[i]++;
  }
  q = 1;
  int t = 0;
  cin >> q;
  while (q--) {
    testcase();
  }
  return 0;
}
