#include <bits/stdc++.h>
using namespace std;
vector<long long> contains;
const long long MAX = 1e18 + 1e5;
bool square(long long x) {
  long long y = sqrt(x);
  if (y * y == x) return 1;
  return 0;
}
void Init() {
  for (int base = (2); base <= (1e6); ++base) {
    long long now = 1ll * base * base;
    while (1.0 * MAX / now > base) {
      now *= base;
      if (!square(now)) contains.push_back(now);
    }
  }
  sort(contains.begin(), contains.end());
  contains.resize(unique(contains.begin(), contains.end()) - contains.begin());
}
void Query() {
  long long n;
  cin >> n;
  long long ans = n - (long long)sqrt(n);
  ans -= upper_bound(contains.begin(), contains.end(), n) - contains.begin();
  cout << ans << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  Init();
  int test;
  cin >> test;
  while (test--) Query();
}
