#include<bits/stdc++.h>
using namespace std; 
long long t,n,d=0,e,a[100005];
bool   snt(long long x)
    {
        for(long long i=2;i<=sqrt(x);i++)
         if(x%i==0)   return false; 
         return (x>1); 
         
    } 
bool   scp(long long m)
{
    long long s;
    s=(long long) sqrt(m);
      if(s*s==m) return true; else return false;
}
int main()
{
 cin.tie(0)->sync_with_stdio(0);
	freopen("TNUM.INP","r",stdin);
    freopen("TNUM.OUT","w",stdout);
	cin>>t;
	while(t--)
     {
         cin>>n;
         if(scp(n)==true and snt((long long) sqrt(n))==true)
             cout<<"YES"<<'\n';
                  else cout<<"NO"<<'\n';
     }
}
