#include <bits/stdc++.h>
using namespace std;
int isperfectsquare(long long n) {
  long long squareRootN = (long long)round((sqrt(n)));
  if (squareRootN * squareRootN == n) {
    return 1;
  } else {
    return 0;
  }
}
int isprime(int number) {
  if (number < 2) return 0;
  if (number == 2) return 1;
  if (number % 2 == 0) return 0;
  for (int i = 3; (i * i) <= number; i += 2) {
    if (number % i == 0) return 0;
  }
  return 1;
}
int main() {
  long long n, a[100000], i, j;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    long long t = a[i];
    if ((isperfectsquare(t) == 1) && (isprime(sqrt(t)) == 1))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
