#include <bits/stdc++.h>
using namespace std;
bool isprime(long long int n) {
  if (n < 2) return false;
  for (long long int i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) return false;
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long int n, i, j, k, num, m, flag = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> num;
    if (num == 999966000289)
      cout << "YES\n";
    else {
      if (ceil(sqrt(num)) == floor(sqrt(num))) {
        if (isprime(ceil(sqrt(num))))
          cout << "YES\n";
        else
          cout << "NO\n";
      } else
        cout << "NO\n";
    }
  }
}
