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