#include <bits/stdc++.h>
using namespace std;
bool primes[1000007];
void fnc() {
  for (int i = 4; i <= 1000000; i += 2) primes[i] = 1;
  primes[1] = 1;
  int limit = sqrt(1000000) + 1;
  for (long long i = 3; i <= 1000000; i += 2) {
    if (!primes[i]) {
      if (i <= limit) {
        for (long long j = i * i; j <= 1000000; j += i * 2) primes[j] = 1;
      }
    }
  }
}
int main() {
  fnc();
  int t;
  cin >> t;
  long long n;
  while (t--) {
    scanf("%I64d", &n);
    long long ck = sqrt(n);
    if (ck * ck != n) {
      printf("NO\n");
      continue;
    }
    if (!primes[ck])
      printf("YES\n");
    else
      printf("NO\n");
  }
}
