#include <bits/stdc++.h>
#define N 10000000
using namespace std;
ifstream f1("CPRIME.inp");
ofstream f2("CPRIME.out");
long long i,j,n,a[10000000],k;
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;
      }
    }
  }
  cin>>n;
  for( i=1;i<=n;++i){
    cin>>a[i];
  }
  for( k=1;k<=n;++k){
    if(check[a[k]]==true){
        cout<<"YES"<<endl;
    }
    if(check[a[k]]==false)
    {
        cout<<"NO"<<endl;
    }
  }
  f1.close();
  f2.close();
}
