#include <bits/stdc++.h>
using namespace std;
const int mn = 1e6 + 5;
int f[mn], d[mn], n, t, ans[mn];
void cal() {
  for (int i = 2; i <= 1000; ++i) {
    int j = i;
    if (d[j]) continue;
    while (j <= mn - 5) {
      j += i;
      if (j > mn - 5) break;
      d[j] = 1;
    }
  }
  for (int i = 1; i <= mn - 5; ++i) {
    f[i] = f[i - 1] + (1 - d[i]);
    ans[i] = 1 + f[i] - f[(int)sqrt(i)];
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cal();
  for (cin >> t; t--; cout << ans[n] << "\n") cin >> n;
  return 0;
}
