#include <bits/stdc++.h>
int compare(const void *a, const void *b) {
  if (*(unsigned long long *)a > *(unsigned long long *)b) {
    return 1;
  } else if (*(unsigned long long *)a < *(unsigned long long *)b) {
    return -1;
  } else {
    return 0;
  }
}
int cnt;
unsigned long long *getList() {
  unsigned long long *list = 0;
  unsigned long long i = 0, j = 0;
  char isPrime[1000000 + 1] = {
      0,
  };
  memset(isPrime, 1, 1000000 + 1);
  isPrime[0] = isPrime[1] = 0;
  for (i = 2; i <= 1000000; i++) {
    if (isPrime[i]) {
      cnt++;
      for (j = i * 2; j <= 1000000; j += i) {
        isPrime[j] = 0;
      }
    }
  }
  list = (unsigned long long *)malloc(sizeof(unsigned long long) * cnt);
  int index = 0;
  for (i = 2; i <= 1000000; i++) {
    if (isPrime[i]) {
      list[index++] = i * i;
    }
  }
  return list;
}
int main(void) {
  unsigned long long *list = getList();
  int n = 0;
  unsigned long long num = 0;
  scanf("%d", &n);
  while (n--) {
    scanf("%llu", &num);
    if (bsearch(&num, list, cnt, sizeof(unsigned long long), compare)) {
      printf("YES\n");
    } else {
      printf("NO\n");
    }
  }
  free(list);
  return 0;
}
