#include <bits/stdc++.h>
using namespace std;
int main() {
  bool prime_squares[1000000 + 5];
  memset(prime_squares, true, sizeof(prime_squares));
  for (int i = 2; i * i <= 1000000 + 5; i++) {
    if (prime_squares[i] == true) {
      for (int j = i * i; j <= 1000000 + 5; j = j + i) {
        prime_squares[j] = false;
      }
    }
  }
  int n;
  cin >> n;
  unsigned long long int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    long long int r = (long long int)sqrt(arr[i]);
    if (arr[i] != 1 && r * r == arr[i] && prime_squares[r] == true) {
      printf("YES\n");
    } else {
      printf("NO\n");
    }
  }
}
