#include <bits/stdc++.h>
using namespace std;
long long n, p, cntr, sq;
long long isprime[(int)1e6 + 1], lookout[(int)1e6 + 1];
vector<long long> v;
void sieve() {
  fill(isprime, isprime + (int)1e6 + 1, 1);
  isprime[0] = isprime[1] = 0;
  for (int i = 4; i < (int)1e6 + 1; i += 2) isprime[i] = 0;
  for (long long i = 3; i < (int)1e6 + 1; ++i)
    if (isprime[i])
      for (long long j = i * i; j < (int)1e6 + 1; j += 2 * i) {
        isprime[j] = 0;
      }
}
int main() {
  cin >> n;
  sieve();
  while (n--) {
    cin >> p;
    sq = sqrt(p);
    if (isprime[sq] && sq * sq == p)
      printf("YES\n");
    else
      printf("NO\n");
    cntr = 0;
  }
  return 0;
}
