#include <bits/stdc++.h>
using namespace std;
bool prime[1000000] = {0};
map<long long, bool> M;
void SieveOfEratosthenes(int n) {
  bool prime[n + 1];
  memset(prime, true, sizeof(prime));
  for (long long p = 2; p < n; p++) {
    if (prime[p] == true) {
      M[p * p] = 1;
      for (int i = p * 2; i <= n; i += p) prime[i] = false;
    }
  }
}
int main() {
  SieveOfEratosthenes(1000000);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    long long a;
    cin >> a;
    if (M[a])
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
