#include using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair P; #define fi first #define se second #define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++) #define rep(i,n) repl(i,0,n) #define all(x) (x).begin(),(x).end() #define dbg(x) cout<<#x"="<y?x:y) #define mmin(x,y) (x operator+(const vector& a,const vector& b){ vector res(a.size(),0); rep(i,a.size())res[i]=a[i]+b[i]; return res; } vector operator-(const vector& a,const vector& b){ vector res(a.size(),0); rep(i,a.size())res[i]=a[i]-b[i]; return res; } bool isprime[2001]; vector ps; int M; vector calcvec(int X){ if(X==0) return vector(M,0); vector res(M,0); rep(i,ps.size()){ while(X%ps[i]==0){ res[i]++; X/=ps[i]; } } if(X!=1) return vector(1,-1); return res; } int N,Q; vector sum[100010]; int zsum[100010]; int main(){ cin.tie(0); ios::sync_with_stdio(false); repl(i,2,2001)isprime[i]=true; for(ll i=2;i<=2000;i++){ if(isprime[i]){ ps.push_back(i); for(ll j=i*2;j<=2000;j+=i)isprime[j]=false; } } M=ps.size(); sum[0]=vector(M,0); cin>>N; rep(i,N){ int A; cin>>A; if(A==0){ zsum[i+1]=zsum[i]+1; }else{ zsum[i+1]=zsum[i]; } vector B=calcvec(A); sum[i+1]=sum[i]+B; } cin>>Q; rep(i,Q){ int P,L,R; cin>>P>>L>>R; L--; vector tmp=sum[R]-sum[L]; vector p=calcvec(P); if(p[0]==-1){ cout<<"NO"<