#include <bits/stdc++.h>
using namespace std;
int A[1000000];
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int64_t num, i, j, ip;
  for (i = 2; i <= 1000000; i++) A[i] = 1;
  for (i = 2; i * i <= 1000000; i++) {
    if (A[i]) {
      for (j = i * 2; j <= 1000000; j += i) A[j] = 0;
    }
  }
  cin >> num;
  while (num--) {
    cin >> ip;
    float ip1 = sqrt(ip);
    if (ip1 == sqrt(ip)) {
      ip = sqrt(ip);
      if (A[ip])
        cout << "YES" << endl;
      else
        cout << "NO" << endl;
    } else
      cout << "NO" << endl;
  }
  return 0;
}
