#include <bits/stdc++.h>
using namespace std;
long long i, j, k, n, m, s;
int p[2000000];
int main() {
  p[1] = 1;
  for (i = 2; i <= 1000; i++) {
    if (p[i]) continue;
    for (k = i + i; k <= 1000000; k += i) p[k] = 1;
  }
  cin >> n;
  while (n--) {
    cin >> k;
    m = sqrt(1.0 * k + 1e-9);
    if (m * m == k && !p[m]) {
      cout << "YES\n";
    } else
      cout << "NO\n";
  }
  return 0;
}
