#include <bits/stdc++.h>

using namespace std;
const int MaxSang = 1000001;
bool snt[MaxSang]={false};
int Prime[100000],t;
#define el '\n'
int L,R;
int d=0,n,x;
void sang()
{
    int i=2;
    while (i<MaxSang)
    {
        while (snt[i]==true)
        {
            i++;
        }
        for (int j=2;j<MaxSang/i;++j)
        {
            snt[i*j]=true;
        }
        i++;
    }
    snt[1]=true;
    snt[0]=true;
    for (int i=2;i<MaxSang;++i)
    {
        if (snt[i]==false)
        {
            Prime[t]=i;
            t++;
        }
    }
}
bool check(int a)
{
    int Can=sqrt(a);
    int k=0;
    while (Prime[k]<=Can)
    {
        if (a%Prime[k]==0) return false;
        k=k+1;
    }
    return true;
}
int main()
{
    freopen("CPrime.inp","r",stdin);
    freopen("CPrime.out","w",stdout);
    ios_base::sync_with_stdio(false);
    sang();
    cin>>n;
    for (int i=0;i<n;i++)
    {
        cin>>x;
        if (x<MaxSang)
        {
            if (snt[x]==false)
            {
                cout<<"YES"<<el;
            }
            else cout<<"NO"<<el;
        }
        else
        {
            if (check(x)==true)
            {
                cout<<"YES"<<el;
            }
            else cout<<"NO"<<el;;
        }
    }
}
