#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  unsigned long long int a;
  unsigned long long int temp;
  unsigned long long int temp2;
  unsigned long long int count = 0;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a == 1) {
      cout << "NO\n";
    } else {
      temp = (unsigned long long int)sqrt(a);
      if (a == (temp * temp)) {
        temp2 = (unsigned long long int)sqrt(temp);
        if ((temp % 2 == 0) && (temp2 >= 2)) {
          count++;
          cout << "NO\n";
        } else {
          for (unsigned long long int j = 3; j <= temp2; j = j + 2) {
            if (temp % j == 0) {
              count++;
              cout << "NO\n";
              break;
            }
          }
        }
        if (count == 0) {
          cout << "YES\n";
        }
        count = 0;
      } else
        cout << "NO\n";
    }
  }
  return 0;
}
