#include <bits/stdc++.h>   using namespace std;   int dx[4] = {0, 0, 1, -1};   int dy[4] = {1, -1, 0, 0};   const int mod = (int)1e9 + 7;   long long INF64 = 3e18;   void smxl(long long &a, long long b) {     if (a < b) a = b;   }   void smnl(long long &a, long long b) {     if (a > b) a = b;   }   void adsl(long long &a, long long b) {     a += b;     if (a >= mod) a -= mod;   }   void misl(long long &a, long long b) {     a -= b;     if (a >= mod) a -= mod;     if (a < 0) a += mod;   }   void smx(long long &a, long long b) {     if (a < b) a = b;   }   void smn(long long &a, long long b) {     if (a > b) a = b;   }   void ads(long long &a, long long b) {     a += b;     if (a >= mod) a -= mod;   }   void mis(long long &a, long long b) {     a -= b;     if (a >= mod) a -= mod;     if (a < 0) a += mod;   }   long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); }   long long egcd(long long a, long long b, long long &x, long long &y) {     if (a == 0) {       x = 0;       y = 1;       return b;     }     long long x1, y1;     long long d = egcd(b % a, a, x1, y1);     x = y1 - (b / a) * x1;     y = x1;     return d;   }   long long mbinp(long long a, long long b) {     a %= mod;     if (b == 0) return 1;     long long ans = mbinp(a, b / 2);     long long tmp = (ans * ans) % mod;     if (b % 2) return ((tmp * a) % mod);     return ((tmp) % mod);   }   long long C(int n, int m) {     long long ret = 1;     for (int i = 1; i <= m; i++) {       ret *= (n - i + 1);       ret /= i;     }     return ret;   }   long long binp(long long a, int b) {     long long res = 1;     while (b) {       if (b & 1) {         if (res < INF64 / a)           res *= a;         else           return INF64;       }       if (b > 1) {         if (a < INF64 / a)           a *= a;         else           return INF64;       }       b >>= 1;     }     return res;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int n;     cin >> n;     vector<int> primes(100, 0);     vector<int> mu(100, 0);     for (int i = 2; i < 100; i++) {       if (primes[i] == 0) {         mu[i]++;         for (int j = 2 * i; j < 100; j += i) {           primes[j] = 1;           if (mu[j] != -1) mu[j]++;         }         for (int z = i * i; z < 100; z += i * i) mu[z] = -1;       }     }     mu[1] = 2;     vector<pair<long long, int> > all(n);     for (int i = 0; i < n; i++) {       cin >> all[i].first;       all[i].second = i;     }     sort(all.rbegin(), all.rend());     vector<long long> poss(62);     for (int i = 3; i < 62; i++)       poss[i] = (long long)ceil(pow((long double)1e18, 1.0 / i));     vector<long long> ans(n);     for (int i = 0; i < n; i++) {       long long skr = -1;       long long low = 0;       long long hi = 1e9 + 10;       while (low <= hi) {         long long mid = (low + hi) / 2;         if (mid * mid <= all[i].first) {           if (mid > skr) skr = mid;           low = mid + 1;         } else           hi = mid - 1;       }       poss[1] = all[i].first;       poss[2] = skr;       for (int j = 3; j < 62; j++) {         while (poss[j] > 0 && binp(poss[j], j) > all[i].first) poss[j]--;       }       long long out = 0;       for (int j = 1; j < 62; j++) {         out += (poss[j] - 1) * (mu[j] == -1 ? 0 : (mu[j] % 2 == 1 ? -1 : 1));       }       ans[all[i].second] = out;     }     for (int i = 0; i < n; i++) cout << ans[i] <<   n ;   }