#include <bits/stdc++.h>
using namespace std;
bool isprime[64];
long long mobius[64];
long long root(long long n, long long i) {
  long double n_eps = double(n) + 0.001;
  long double n_fl = n;
  long long res = pow(n_fl, 1.0 / float(i));
  while (pow(res + 1, i) < n_eps) {
    res++;
  }
  while (pow(res, i) > n_fl) {
    res--;
  }
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  long long n, r, f;
  int t, pc;
  cin >> t;
  for (int i = 2; i < 64; i++) {
    isprime[i] = true;
    mobius[i] = 1;
    pc = 0;
    for (int j = 2; j < i; j++) {
      if (i % j == 0) {
        isprime[i] = false;
        if (isprime[j]) {
          pc++;
        }
        if (isprime[j] && (i % (j * j) == 0)) {
          mobius[i] = 0;
        }
      }
    }
    if (!isprime[i] && (mobius[i] == 1) && (pc % 2 == 0)) {
      mobius[i] = -1;
    }
  }
  while (t--) {
    cin >> n;
    r = n - 1;
    for (int i = 2; i < 64; i++) {
      f = root(n, i);
      r -= mobius[i] * (f - 1);
      if (f == 1) {
        break;
      }
    }
    cout << r << endl;
  }
  return 0;
}
