#include <bits/stdc++.h>
using namespace std;
const int LIM = 1000006;
int pr[LIM];
void seive() {
  pr[0] = 1;
  pr[1] = 1;
  int root = sqrt(LIM);
  for (int i = 2; i <= root; i++) {
    if (pr[i] == 0) {
      for (int j = i * i; j < LIM; j += i) pr[j] = 1;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  seive();
  int tt;
  cin >> tt;
  while (tt--) {
    long long int a;
    cin >> a;
    long long int root = sqrt(a);
    if (root * root == a && pr[root] == 0)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
