#include <bits/stdc++.h>
using namespace std;
bool compute(long long n) {
  long double i = sqrt(n);
  long long i2 = sqrt(n);
  if (i != i2) {
    return false;
  }
  if (i2 <= 1) {
    return false;
  }
  if (i2 <= 3) {
    return true;
  }
  if (i2 % 2 == 0 || i2 % 3 == 0) {
    return false;
  }
  for (long long i = 5; i <= sqrt(i2); i = i + 6) {
    if (n % i == 0 || n % (i + 2) == 0) {
      return false;
    }
  }
  return true;
}
int main(int argc, char const *argv[]) {
  long long n;
  cin >> n;
  long long a[n];
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (long long i = 0; i < n; ++i) {
    bool ans = compute(a[i]);
    if (ans) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
