#include <bits/stdc++.h>
using namespace std;
const int m = 1000005;
int e[m], a[m];
void s() {
  e[1] = 1;
  for (int i = 2; i < m; i++) {
    e[i] = i;
  }
  for (int i = 2; i < m; i++) {
    if (e[i] == i) {
      for (int j = i; j < m; j = j + i) {
        e[j] = e[j] / i * (i - 1);
        if (j - e[j] == 1) {
          a[j] = 1;
        }
      }
    }
  }
}
int main() {
  long long n, k, x;
  cin >> n;
  s();
  for (int i = 1; i <= n; i++) {
    cin >> k;
    x = sqrt(k);
    if (x * x == k && a[x] == 1) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
