#include<iostream>
#include<math.h>
using namespace std;

bool isPrime(long long n){
    if (n<2) return false;
    if (n<4) return true;
    if (n%2==0) return false;
    for (long long i=3; i*i<=n; i+=2){
        if (n%i==0) return false;
    }
    return true;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen ("input.txt", "r", stdin);
    freopen ("output.txt", "w", stdout);
#endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n;
    long long x, t;
    cin >> n;
    for (int i=0; i<n; i++){
        cin >> x;

        if (sqrt(x) != (long long)sqrt(x)) {
            cout << "NO\n";
            continue;
        }
        if (isPrime((long long)sqrt(x))) cout << "YES\n"; else cout << "NO\n";
    }

    return 0;
}