#include <bits/stdc++.h>
using namespace std;
bool prime[100000001];
void sieve() {
  int n = 10000000;
  memset(prime, true, sizeof(prime));
  for (int i = 2; i * i <= n; i++) {
    if (prime[i]) {
      for (int j = 2 * i; j <= n; j += i) {
        prime[j] = false;
      }
    }
  }
}
int main() {
  sieve();
  int n;
  cin >> n;
  long long int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    long long int x = (long long int)sqrt(a[i]);
    if ((x * x == a[i]) && prime[x] && x != 1)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
