#include <bits/stdc++.h>
using namespace std;
bool isprime[1000005];
vector<int> prime;
void precompute() {
  int i, j;
  memset(isprime, true, sizeof(isprime));
  isprime[0] = 0;
  isprime[1] = false;
  for (i = 2; i * i < 1000005; i++)
    if (isprime[i])
      for (j = i + i; j < 1000005; j += i) isprime[j] = false;
  return;
}
int main() {
  precompute();
  int i, n;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    long long int x;
    cin >> x;
    long long int ans = 1, cnt = 0;
    long long int sq = sqrt(x);
    if (sq * sq == x && isprime[sq] == true) {
      puts("YES");
    } else
      puts("NO");
  }
  return 0;
}
