#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-10;
const double Pi = 3.1415926535897932;
const int dir[4][2] = {-1, 0, 0, -1, 1, 0, 0, 1};
const int maxn = 2e6;
long long w[maxn];
int pn = 0;
const long long N = 1e18;
int main() {
  for (long long i = 2; i <= 1e6; i++) {
    long long t = i * i;
    while (t <= N / i) {
      t *= i;
      long long tmp = sqrt(t);
      if (tmp * tmp < t) w[++pn] = t;
    }
  }
  sort(w + 1, w + 1 + pn);
  pn = unique(w + 1, w + 1 + pn) - w - 1;
  int T;
  scanf("%d", &T);
  while (T--) {
    long long n;
    scanf("%lld", &n);
    long long ans = n - ((long long)sqrt(n));
    ans -= upper_bound(w + 1, w + 1 + pn, n) - w - 1;
    printf("%lld\n", ans);
  }
  return 0;
}
