#include <bits/stdc++.h>
using namespace std;
long long i, N, j, check = 1;
long long test, sq;
long long n[1000000];
int main() {
  cin >> N;
  for (i = 3; i <= 1000; i = i + 2) {
    if (n[i] == 0) {
      for (j = i * i; j <= 1000000; j += i + i) n[j] = 1;
    }
  }
  for (i = 0; i < N; i++) {
    cin >> test;
    sq = sqrt(test);
    if (sq * sq == test && test != 1) {
      if (test == 4)
        cout << "YES" << endl;
      else if (test % 2 == 0)
        cout << "NO" << endl;
      else if (n[sq] == 0)
        cout << "YES" << endl;
      else
        cout << "NO" << endl;
    } else
      cout << "NO" << endl;
  }
  return 0;
}
