#include <bits/stdc++.h>
using namespace std;
long long a[(30000000 + 5000)], tot = 0, T, n;
int squ(long long N) {
  long long Rt = sqrt(N);
  if (Rt * Rt == N) return 1;
  return 0;
}
int main() {
  for (long long i = 2; i <= 1000000; ++i) {
    long long tmp = i * i;
    while (tmp <= ((long long)(1e18)) / i) {
      tmp *= i;
      if (!squ(tmp)) a[++tot] = tmp;
    }
  }
  sort(a + 1, a + 1 + tot);
  tot = (long long)(unique(a + 1, a + 1 + tot) - a - 1);
  scanf("%lld", &T);
  while (T--) {
    scanf("%lld", &n);
    long long pos = upper_bound(a + 1, a + 1 + tot, n) - a - 1;
    printf("%lld\n", n - pos - (long long)sqrt(n));
  }
  return 0;
}
