#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 10;
long long i;
long long arr[maxn];
bool isprime(long long x) {
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0) return false;
  }
  return true;
}
int main() {
  int n;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (i = 0; i < n; i++) {
    if (arr[i] <= 1) {
      cout << "NO" << endl;
      continue;
    }
    long long t = sqrt(arr[i]);
    if (t * t != arr[i]) {
      cout << "NO" << endl;
      continue;
    }
    if (isprime(t)) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}
