#include <bits/stdc++.h>
using namespace std;
bool sieve[1000002];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long xd = 1000000;
  vector<long long> vec;
  for (unsigned long long i = 2; i <= xd; i++) {
    if (!sieve[i]) {
      vec.push_back(i);
      for (long long j = 2 * i; j <= 1000000; j += i) sieve[j] = 1;
    }
  }
  set<long long> tprim;
  for (unsigned long long i = 0; i < vec.size(); i++) {
    tprim.insert(vec[i] * vec[i]);
  }
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    if (tprim.count(x))
      cout << "YES";
    else
      cout << "NO";
    cout << '\n';
  }
  return 0;
}
