#include <bits/stdc++.h>
using namespace std;
long long n;
bool prime[1000100];
int main() {
  memset(prime, 1, sizeof(prime));
  for (long long i = 3; i < 1000100; i++)
    if (i % 2 == 0) prime[i] = 0;
  long long t = sqrt(1000100 * 1.0);
  for (long long i = 2; i <= t; i++) {
    if (prime[i]) {
      for (long long j = 2 * i; j < 1000100; j += i) {
        prime[j] = 0;
      }
    }
  }
  cin >> n;
  long long x;
  for (long long i = 0; i < n; i++) {
    scanf("%I64d", &x);
    if (x == 1 || x == 0) {
      cout << "NO\n";
      continue;
    }
    long long shuzi = sqrt(1.0 * x);
    if (sqrt(1.0 * x) - shuzi > 0) {
      cout << "NO\n";
      continue;
    }
    if (prime[shuzi]) {
      cout << "YES\n";
    } else {
      cout << "NO\n";
    }
  }
}
