#include <bits/stdc++.h>
using namespace std;
ifstream f("cprime.inp");
ofstream g("cprime.out");
long long n,a[10000000];
long long i,j;
long long N = 10000000;
int main ()
{
  bool check[N + 1];
  for ( i = 2; i <= N; i++) {
    check[i] = true;
  }
  for (i = 2; i <= N; i++) {
    if (check[i] == true) {
      for (j = 2 * i; j <= N; j += i) {
        check[j] = false;
      }
    }
  }
	f>>n;
	for (i=1;i<=n;i++)
	{
		f>>a[i];
	}
	for (i=1;i<=n;i++)
	{ if (check[a[i]]==true)
	  g<<"YES"<<endl;
	  else
	  g<<"NO"<<endl;
}
	f.close();
	g.close();
}
