#include <bits/stdc++.h>
using namespace std;
int mb[60];
long long int pw(long long int a, long long int k) {
  long long int ap = a, ans = 1;
  while (1) {
    if (k & 1) {
      if (ans >= ((long long int)(1e18) + ap) / ap) {
        ans = (long long int)(1e18) + 1;
        break;
      }
      ans *= ap;
    }
    k >>= 1;
    if (k == 0) break;
    if (ap > (long long int)(1e9)) {
      ans = (long long int)(1e18) + 1;
      break;
    }
    ap = ap * ap;
  }
  return ans;
}
long long int root(long long int n, long long int m) {
  long long int n1 = 1, n2;
  if (m > 18)
    n2 = 10;
  else if (m >= 10)
    n2 = 100;
  else if (m >= 5)
    n2 = 5000;
  else if (m == 3)
    n2 = (long long int)(1e6) + 1;
  else
    n2 = (long long int)(1e9) + 1;
  while (n1 != n2) {
    long long int nm = (n1 + n2 + 1) / 2;
    if (pw(nm, m) <= n)
      n1 = nm;
    else
      n2 = nm - 1;
  }
  return n1 - 1;
}
long long int solve(long long int n) {
  long long int ans = n - 1;
  for (long long int i = 2; i < 60; i++) {
    if (mb[i] != 0) {
      ans += (long long int)mb[i] * root(n, i);
    }
  }
  return ans;
}
int main() {
  int t;
  scanf("%d", &t);
  for (int i = 2; i < 60; i++) {
    int i1 = i;
    mb[i] = 1;
    for (int j = 2; j < 60; j++) {
      if (i1 % j == 0) {
        int e = 0;
        while (i1 % j == 0) i1 /= j, e++;
        if (e > 1)
          mb[i] = 0;
        else
          mb[i] = -mb[i];
      }
    }
  }
  for (int i = 0; i < t; i++) {
    long long int n;
    scanf("%lld", &n);
    printf("%lld\n", solve(n));
  }
  return 0;
}
