#include <bits/stdc++.h>
using namespace std;
long long Prime[1000005];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, x;
  Prime[0] = Prime[1] = 1;
  for (long long i = 4; i <= 1000000; i += 2) Prime[i] = 1;
  for (long long i = 3; i <= 1000000; i += 2) {
    if (Prime[i] == 0)
      for (long long j = i * i; j <= 1000000; j += i) {
        Prime[j] = 1;
      }
  }
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x;
    long long val = sqrt(x);
    if (Prime[val] == 0 && (val * val == x))
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
