#include <bits/stdc++.h>
using namespace std;
bool prime[1000007];
void SieveOfEratosthenes() {
  memset(prime, true, sizeof(prime));
  for (int p = 2; p * p <= 1000002; p++) {
    if (prime[p] == true) {
      for (int i = p * 2; i <= 1000002; i += p) prime[i] = false;
    }
  }
}
int main() {
  SieveOfEratosthenes();
  prime[1] = 0;
  long long int t, n;
  cin >> t;
  while (t--) {
    cin >> n;
    long long int k = sqrt(n);
    if (k * k != n)
      cout << "NO\n";
    else {
      if (prime[k])
        cout << "YES\n";
      else
        cout << "NO\n";
    }
  }
  return 0;
}
