#include <bits/stdc++.h>
using namespace std;
int n;
struct comp {
  bool operator()(const int &a, const int &b) { return a < b; }
};
int last = 1000001;
bool p[1000005];
set<long long> valid;
void primes() {
  memset(p, true, sizeof(p));
  p[1] = false;
  for (int i = 2; i * i < last; i++) {
    if (!p[i]) continue;
    for (int j = i * i; j < last; j += i) {
      p[j] = false;
    }
  }
  for (int i = int(1); i <= int(last); i++) {
    if (p[i]) {
      valid.insert((long long)i * i);
    }
  }
}
long long num;
int main() {
  int T;
  scanf("%d", &T);
  float f;
  primes();
  for (int i = int(1); i <= int(T); i++) {
    scanf("%I64d", &num);
    if (valid.find(num) != valid.end()) {
      cout << "YES" << endl;
    } else
      cout << "NO" << endl;
  }
}
