#include <bits/stdc++.h>
using namespace std;
const int maxn = 65;
bool vis[maxn];
int mu[maxn];
int prim[maxn];
int cnt;
void init() {
  memset(vis, 0, sizeof(vis));
  memset(mu, 0, sizeof(mu));
  mu[1] = 1;
  for (int i = 2; i <= maxn - 1; ++i) {
    if (!vis[i]) {
      prim[++cnt] = i;
      mu[i] = -1;
    }
    for (int j = 1; j <= cnt && 1ll * prim[j] * i < maxn; ++j) {
      vis[prim[j] * i] = 1;
      if (i % prim[j] == 0)
        break;
      else
        mu[prim[j] * i] = -mu[i];
    }
  }
}
int main() {
  init();
  int caseCnt;
  scanf("%d", &caseCnt);
  while (caseCnt--) {
    long long n;
    scanf("%lld", &n);
    long long ans = n - 1;
    for (int i = 2; i < maxn; ++i) {
      long long x =
          (long long)powl((long double)n + 0.3, (long double)1.0 / i) - 1;
      ans += x * mu[i];
    }
    printf("%lld\n", ans);
  }
  return 0;
}
