#include <bits/stdc++.h>
#pragma gcc optimize("Ofast")
using namespace std;
vector<long long> v;
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  for (long long i = 2; i <= 1e6; ++i) {
    long long res = i;
    while (res <= 1e18 && log10(res) + log10(i) <= 18) {
      res *= i;
      long long s = sqrt(res);
      if (s * s != res) v.emplace_back(res);
    }
  }
  sort((v).begin(), (v).end());
  v.erase(unique((v).begin(), (v).end()), v.end());
  long long t, n;
  cin >> t;
  while (t--) {
    cin >> n;
    cout << (n - 1) -
                ((upper_bound((v).begin(), (v).end(), n) - v.begin() - 1) +
                 (long long)sqrt(n))
         << '\n';
  }
}
