#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e6 + 5;
const long long inf = 1e6 + 55;
vector<bool> isprime(MAX, true);
map<long long, bool> m;
void seive() {
  isprime[0] = isprime[1] = 0;
  for (long long i = 2; i <= inf; i++) {
    if (isprime[i]) {
      m[i * i] = 1;
      for (int j = 2 * i; j <= MAX; j += i) isprime[j] = 0;
    }
  }
}
int main() {
  seive();
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    long long x;
    scanf("%I64dd", &x);
    if (m[x])
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
