#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, i, p, x = 1;
  vector<long long int> prime(1000005, 1);
  vector<long long int> a(100005, 0);
  prime[0] = 0;
  prime[1] = 0;
  for (p = 2; p * p <= 1000000; p++) {
    if (prime[p] == 1) {
      for (i = p * p; i <= 1000000; i = i + p) prime[i] = 0;
    }
  }
  cin >> n;
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 0; i < n; i++) {
    long long int temp = sqrt(a[i]);
    if (temp * temp != a[i])
      cout << "NO" << endl;
    else if (prime[temp] == 0)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
  return 0;
}
