#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxN = 1001010;
bool isPrime[maxN];
void sieve() {
  for (int i = 0; i < maxN; i++) isPrime[i] = true;
  isPrime[0] = isPrime[1] = false;
  for (int i = 2; i * i < maxN; i++) {
    if (isPrime[i]) {
      for (int j = i * i; j < maxN; j += i) {
        isPrime[j] = false;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  sieve();
  while (n--) {
    ll x;
    cin >> x;
    ll root = sqrt(x);
    if (root == sqrt(x) && isPrime[root])
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
