#include <bits/stdc++.h>
using namespace std;
long long fastPrime(long long n) {
  if (n == 2) return true;
  if (n % 2 == 0) return false;
  for (long long i = 3; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, val;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> val;
    long long sr = sqrt(val);
    if (val != 1 && fastPrime(sr) && sr * sr == val)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
