#include <bits/stdc++.h>
using namespace std;
const int N = 1e6;
bool prime[N + 10];
vector<long long> v;
void Sieve() {
  prime[0] = prime[1] = 1;
  for (long long i = 4; i <= N; i += 2) prime[i] = 1;
  for (long long i = 3; i <= N / i; i += 2) {
    if (!prime[i]) {
      for (long long j = i * i; j <= N; j += i + i) prime[j] = 1;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  Sieve();
  for (long long i = 2; i <= N; i += 1 + (i & 1)) {
    if (!prime[i]) {
      v.push_back(i * i);
    }
  }
  int t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    if (binary_search(v.begin(), v.end(), n))
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
