#include <bits/stdc++.h>
using namespace std;
bool ans[10000007];
void isPrime(long long n) {
  memset(ans, true, sizeof(ans));
  ans[0] = 0;
  ans[1] = 0;
  for (long long i = 2; i * i <= n; i++) {
    for (long long j = i * 2; j <= n; j += i) {
      ans[j] = false;
    }
  }
}
int main() {
  isPrime(1000007);
  long long n;
  cin >> n;
  long long a[n], i;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < n; i++) {
    long long x = sqrt(a[i]);
    if ((x * x) != a[i] or ans[x] == false)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
  return 0;
}
