#include <bits/stdc++.h>
using namespace std;
long long n, a;
bool isPrime[1000004];
int main() {
  cin >> n;
  isPrime[0] = false;
  isPrime[1] = true;
  for (int i = 2; i * i <= 1e6; ++i) {
    if (isPrime[i] == false) {
      for (int j = i * i; j <= 1e6; j += i) isPrime[j] = true;
    }
  }
  for (int i = 1; i <= n; i++) {
    cin >> a;
    long long k = sqrt(a);
    if (isPrime[k] == false && k * k == a) {
      cout << "YES" << endl;
    } else
      cout << "NO" << endl;
  }
}
