#include <bits/stdc++.h>
using namespace std;
int test;
bool prime[1000005];
void snt() {
  for (int i = 2; i <= 1000000; ++i) prime[i] = true;
  for (int i = 2; i <= sqrt(1000000); ++i) {
    if (prime[i] == true) {
      for (int j = i * i; j <= 1000000; j += i) {
        prime[j] = false;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> test;
  snt();
  while (test) {
    --test;
    long long n;
    cin >> n;
    long long x = sqrt(n);
    if (x * x == n && prime[x] == true) {
      cout << "YES" << '\n';
    } else
      cout << "NO" << '\n';
  }
  return 0;
}
