#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 300100;
vector<long long> vec;
void precalc() {
  for (long long i = 2; i < 1000000; i++) {
    long long x = 1ll * i * i;
    while (x + 0.0 < (2e18 + 100) / i) {
      x *= 1ll * i;
      if ((long long)sqrt(x) * (long long)(sqrt(x)) != x) vec.push_back(x);
    }
  }
  sort((vec).begin(), (vec).end());
  unique((vec).begin(), (vec).end());
}
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  long long i = 0;
  precalc();
  long long t;
  cin >> t;
  while (t--) {
    long long x;
    cin >> x;
    cout << x - (upper_bound((vec).begin(), (vec).end(), x) - vec.begin() +
                 (long long)sqrt(x))
         << '\n';
  }
}
