#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, size = 1e6 + 1;
  cin >> n;
  vector<int> prime(1e6 + 1, 1);
  prime[0] = 0;
  prime[1] = 0;
  for (int ri = 2; ri <= sqrt(size); ri++) {
    if (prime[ri]) {
      for (int pi = ri * ri; pi <= size; pi += ri)
        if (prime[pi]) prime[pi] = 0;
    }
  }
  vector<long long int> tprime;
  for (long long int ri = 0; ri < size; ri++) {
    if (prime[ri]) {
      tprime.push_back(ri * ri);
    }
  }
  long long int arr[n];
  for (int ri = 0; ri < n; ri++) scanf("%lld", &arr[ri]);
  for (int ri = 0; ri < n; ri++) {
    bool val = binary_search(tprime.begin(), tprime.end(), arr[ri]);
    if (val)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
