#include <bits/stdc++.h>
using namespace std;
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 1000010;
const int mod = 998244353;
long long n, k;
long long a[maxn];
map<long long, int> m;
int v[maxn];
void primes(int n) {
  memset(v, 0, sizeof v);
  for (int i = 2; i <= n; ++i) {
    if (v[i]) continue;
    for (int j = i; j <= n / i; ++j) v[i * j] = 1;
  }
}
int main() {
  primes(1000000);
  for (long long i = 2; i <= 1000000; ++i) {
    if (!v[i]) m[i * i] = 1;
  }
  scanf("%lld", &n);
  for (int i = 1; i <= n; ++i) scanf("%lld", &a[i]);
  for (int i = 1; i <= n; ++i) {
    if (m[a[i]])
      printf("YES\n");
    else
      printf("NO\n");
  }
}
