#include <bits/stdc++.h>
using namespace std;
long long arr[1000000 + 10];
bool primes[1000000 + 10];
void seive(void) {
  primes[0] = 1;
  primes[1] = 1;
  for (int i = 4; i <= 1000000; i += 2) {
    primes[i] = 1;
  }
  for (int i = 3; i * i <= 1000000; i += 2) {
    if (!primes[i]) {
      for (int j = i * i; j <= 1000000; j += i * 2) {
        primes[j] = 1;
      }
    }
  }
}
int main() {
  seive();
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (int i = 0; i < n; i++) {
    long long d = sqrt(arr[i]);
    if (d * d == arr[i]) {
      long long c = d;
      if (!primes[c]) {
        cout << "YES" << endl;
      } else
        cout << "NO" << endl;
    } else
      cout << "NO" << endl;
  }
  return 0;
}
