#include <bits/stdc++.h>
using namespace std;
vector<long long> v(100000);
set<long long> pr;
bool a[1000001] = {0};
int n;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  for (long long i = 2; i <= 1000000; i++) {
    if (!a[i]) {
      pr.insert(i * i);
      for (long long j = i * i; j <= 1000000; j += i) {
        a[j] = 1;
      }
    }
  }
  bool b;
  for (int i = 0; i < n; i++) {
    if (pr.find(v[i]) != pr.end())
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
