#include <bits/stdc++.h>
using namespace std;
bool TP[1000001] = {false};
vector<long long> P;
long long N, X, T[100000];
void primos() {
  P.push_back(4);
  for (long long i = 3; i < 1000000; i += 2) {
    if (!TP[i]) {
      P.push_back(i * i);
      TP[i] = false;
      for (long long j = 1; j * i <= 1000001; j++) {
        TP[j * i] = true;
      }
    }
  }
}
int main() {
  cin >> N;
  primos();
  for (int i = 0; i < N; i++) {
    cin >> X;
    T[i] = X;
  }
  for (long long i = 0; i < N; i++) {
    printf("%s\n", binary_search(P.begin(), P.end(), T[i]) ? "YES" : "NO");
  }
  return 0;
}
