#include <bits/stdc++.h>
using namespace std;
int n;
vector<long long int> a;
set<int> p;
int pm[int(1e6 + 1)];
void sieve() {
  for (int i = 2; i < int(1e6 + 1); i++)
    if (!pm[i]) {
      p.insert(i);
      for (int j = i; j < int(1e6 + 1); j += i) pm[j] = 1;
    }
  return;
}
void inp() {
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  return;
}
bool check(long long int x) {
  long long int m = sqrt(x);
  if (p.count(m) && m * m == x) return true;
  return false;
}
void solve() {
  sieve();
  for (auto i : a)
    if (check(i))
      cout << "YES\n";
    else
      cout << "NO\n";
  return;
}
int main() {
  clock_t beg = clock();
  {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
  };
  inp();
  solve();
  clock_t end = clock();
  fprintf(stderr, "%.3f sec\n", (double)(end - beg) / CLOCKS_PER_SEC);
  return 0;
}
