#include using namespace std; typedef long long ll; vector prime; vector> factorize(ll p){ vector> ret; for(auto i:prime){ if(i>p) break; ll cnt=0; while(p%i==0){ p/=i; cnt++; } if(cnt){ ret.push_back(make_pair(i,cnt)); } } return ret; } ll sum[100010][333]; signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20); ll n; cin>>n; vector>> a(n+1); bool check[2222]={}; ll pnum[2222]={}; ll cnt=0; for(ll i=2;i<=2000;i++){ if(check[i]==0){ for(ll j=i+i;j<=2000;j+=i){ check[j]=1; } prime.push_back(i); pnum[i] = cnt; cnt++; } } for(ll i=1;i<=n;i++){ ll t; cin>>t; a[i] = factorize(t); for(auto j:a[i]){ sum[i][pnum[j.first]]+=j.second; } for(ll j=0;j<333;j++){ sum[i][j] += sum[i-1][j]; } } ll q; cin>>q; while(q--){ ll p,l,r; cin>>p>>l>>r; l--; ll c[333]; for(ll i=0;i<333;i++){ c[i] = sum[r][i] - sum[l][i]; while(c[i] && p%prime[i]==0){ p/=prime[i]; c[i]--; } } if(p==1){ cout<<"Yes\n"; } else cout<<"NO\n"; } }