#include <fstream>
using namespace std;
int snt(long int m)
{
	if (m<2)
	return 0;
	if (m==2)
	return 1;
	else
	for (int b=2;b<=m/2;b++)
	{ 
	if (m%b==0)
	return 0;
	}
	return 1;
}
int main ()
{
	ifstream f("cprime.inp");
	ofstream g("cprime.out");
	long int n,a[9999999];
	int i;
	f>>n;
	for (i=1;i<=n;i++)
	{ 
		f>>a[i];
	}
	for (i=1;i<=n;i++)
	{
		if (snt(a[i])==1)
		g<<"YES"<<endl;
		else
		g<<"NO"<<endl;
	}
}
