#include <bits/stdc++.h>
using namespace std;
long b[1000000];
bool sangsnt(long e, long d)
{
	for (long i=1; i<=d; i++)
		if (e%b[i]==0) return false;
		return true;
	
}
int main ()
{
	freopen ("CPRIME.inp", "r", stdin);
	freopen ("CPRIME.out", "w", stdout);
	long n,d=1,e,c;
	b[d]=2;
	cin>> n;
	long a[n+1];
	for (long i=1; i<=n; i++)
	cin>> a[n];
	for (long i=1; i<=n; i++)
	{
		if (a[i]<b[d]) 
		{c=1;
		while (b[c]<a[i])
		c++;
		if (b[c]==a[i]) cout << "YES" << endl;
		else cout << "NO";
		}	
		else 
		{
			c=b[d]+1;
			while (b[d]<a[i]&&c<a[i])
			if (sangsnt(c,d)==true) {d++; b[d]=c; c++;}
			else c++;
			if (a[i]==b[d]) cout << "YES"<<endl;
			else cout << "NO";
		}
}
}
