#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 7;
bool isp[maxn];
void init() {
  isp[0] = isp[1] = true;
  for (int i = 2; i <= 1000; i++) {
    for (int j = i * 2; j < maxn; j += i) {
      isp[j] = true;
    }
  }
}
int main() {
  int n;
  cin >> n;
  init();
  while (n--) {
    long long x;
    scanf("%lld", &x);
    long long m = (long long)sqrt(x + 0.5);
    if (m * m == x && !isp[m]) {
      puts("YES");
    } else {
      puts("NO");
    }
  }
  return 0;
}
