#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;

int T;
map<int,bool> mp;
bool f[N];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	for(int i=2;i<N;i++){
		if(!f[i]){
			mp[i]=true;
			for(int j=i*2;j<N;j+=i){
				f[j]=true;
			}
		}
	}
	
	cin>>T;
	int n;
	while(T--){
		cin>>n;
		if(mp[n]==true){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}

    return 0;
}