#pragma GCC optimize("Ofast")
#pragma GCC optimize("O2")
#include<bits/stdc++.h>
#define int long long
#define FOR(i,l,r,n) for((i)=(l);(i)<=(r);(i)+=(n))
#define FOD(i,r,l,n) for((i)=(r);(i)>=(l);(i)-=(n))
#define end "\n"
using namespace std;
const int N=1e7+1; short f[N]={};
void sieve()
{
int i,j;
FOR(i,2,sqrt(N),1)
{
if (f[i]==0)
{
FOR(j,i*i,N,i) f[j]=1;
}
}
f[1]=1; f[0]=1;
}
signed main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
sieve();
int n; cin>>n; while (n--)
{
int x; cin>>x;
if (f[x]==0) cout<<"YES"; else cout<<"NO"; cout<<end;
}
return 0;
}
I3ByYWdtYSBHQ0Mgb3B0aW1pemUoIk9mYXN0IikKI3ByYWdtYSBHQ0Mgb3B0aW1pemUoIk8yIikKI2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KCiNkZWZpbmUgaW50IGxvbmcgbG9uZwojZGVmaW5lIEZPUihpLGwscixuKSBmb3IoKGkpPShsKTsoaSk8PShyKTsoaSkrPShuKSkKI2RlZmluZSBGT0QoaSxyLGwsbikgZm9yKChpKT0ocik7KGkpPj0obCk7KGkpLT0obikpCiNkZWZpbmUgZW5kICJcbiIgCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmNvbnN0IGludCBOPTFlNysxOyBzaG9ydCBmW05dPXt9Owp2b2lkIHNpZXZlKCkKewoJaW50IGksajsKCUZPUihpLDIsc3FydChOKSwxKQoJewoJCWlmIChmW2ldPT0wKQoJCXsKCQkJRk9SKGosaSppLE4saSkgZltqXT0xOwoJCX0KCX0KCWZbMV09MTsgZlswXT0xOwp9CnNpZ25lZCBtYWluKCkKewoJaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbygwKTsgY2luLnRpZSgwKTsgY291dC50aWUoMCk7CglzaWV2ZSgpOwoJaW50IG47IGNpbj4+bjsgd2hpbGUgKG4tLSkKCXsKCQlpbnQgeDsgY2luPj54OwoJCWlmIChmW3hdPT0wKSBjb3V0PDwiWUVTIjsgZWxzZSBjb3V0PDwiTk8iOyBjb3V0PDxlbmQ7Cgl9CglyZXR1cm4gMDsKfQoK