#include <bits/stdc++.h>
using namespace std;
int n;
bool flag[1000001];
map<long long, int> Q;
int main() {
  memset(flag, true, sizeof(flag));
  flag[0] = flag[1] = false;
  for (int i = 2; i <= 1000001 - 1; i++)
    if (flag[i]) {
      Q[1LL * i * i] = 1;
      for (int j = 2; j * i < 1000001; j++) flag[j * i] = false;
    }
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    long long t;
    scanf("%lld", &t);
    if (Q[t])
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
