#include <bits/stdc++.h>
using namespace std;
const long long q = 1e6;
char d[q];
bool q1[q] = {};
int main() {
  for (int u = 2; u < q; u++) {
    if (q1[u]) continue;
    for (int j = u; j < q; j += u) {
      q1[j] = 1;
    }
    d[u] = 'p';
  }
  long long int n, x;
  cin >> n;
  for (int y = 0; y < n; y++) {
    cin >> x;
    long long int c = sqrt(x);
    if (c * c != x) {
      cout << "NO" << endl;
      continue;
    }
    if (d[c] == 'p')
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
