#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long y = pow(10, 6), x = *max_element(a, a + n);
  if (x < y)
    ;
  else
    x = y;
  bool prime[x + 1];
  memset(prime, true, sizeof(prime));
  prime[1] = false;
  for (long long i = 2; i < x + 1; i++) {
    if (prime[i]) {
      for (long long j = i * i; j < x + 1; j += i) {
        prime[j] = false;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    double t = sqrt(a[i]);
    double k = floor(t);
    if (k == t) {
      long long h = k;
      if (prime[h])
        cout << "YES" << endl;
      else
        cout << "NO" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}
