#include <bits/stdc++.h>

using namespace std;
const int MaxSang = 10000001;
int Prime[1000000],t;
#define el '\n'
int L,R;
int n,x;

#define limit 10000000
bool sieve[100000000];
int snt[MaxSang],d=3;
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 SieveOfAtkin()
{
    snt[1]=2;snt[2]=3;
    for (int x = 1; x * x < limit; x++)
    {
        for (int y = 1; y * y < limit; y++)
        {
            int n = (4 * x * x) + (y * y);
            if (n <= limit && (n % 12 == 1 || n % 12 == 5))
                sieve[n] ^= true;
            n = (3 * x * x) + (y * y);
            if (n <= limit && n % 12 == 7)
                sieve[n] ^= true;
            n = (3 * x * x) - (y * y);
            if (x > y && n <= limit && n % 12 == 11)
                sieve[n] ^= true;
        }
    }
    for (int r = 5; r * r < limit; r++)
    {
        if (sieve[r]==true)
        {
            for (int i = r * r; i < limit; i += r * r)
                sieve[i] = false;
        }
    }
    for (int a = 5; a < limit; a++)
        if (sieve[a]==true)
        {
            snt[d]=a;
            d++;
        }
}
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 (snt[x]==false)
            {
                cout<<"YES"<<el;
            }
            else cout<<"NO"<<el;
        }
    }
}
