#include <bits/stdc++.h>
using namespace std;
const int maxn = 100007;
long long a[maxn];
const long long MAXN = 1000007;
int prime[MAXN];
bool vis[MAXN];
void Prime(long long n) {
  int cnt = 0;
  memset(vis, 0, sizeof(vis));
  vis[1] = 1;
  for (int i = 2; i < n; i++) {
    if (!vis[i]) prime[cnt++] = i;
    for (int j = 0; j < cnt && i * prime[j] < n; j++) {
      vis[i * prime[j]] = 1;
      if (i % prime[j] == 0) break;
    }
  }
}
int main() {
  Prime(MAXN - 1);
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%I64d", &a[i]);
  }
  for (int i = 1; i <= n; i++) {
    long long tmp = sqrt(a[i]);
    if (tmp * tmp != a[i]) {
      cout << "NO" << endl;
    } else if (vis[tmp]) {
      cout << "NO" << endl;
    } else
      cout << "YES" << endl;
  }
}
