#include <bits/stdc++.h>
using namespace std;
bool isprime(int u) {
  if (u <= 1) return false;
  if (u <= 3) return true;
  if (u % 2 == 0 || u % 3 == 0) return false;
  for (int i = 5; i * i <= u; i = i + 6) {
    if (u % i == 0 || u % (i + 2) == 0) {
      return false;
    }
  }
  return true;
}
bool gg(long long x) {
  int y = (int)sqrt(x);
  if (1LL * y * y != x) return false;
  return isprime(y) ? true : false;
}
int main() {
  int a;
  long long b;
  cin >> a;
  for (int i = 1; i <= a; i++) {
    cin >> b;
    if (gg(b))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
