#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned int ui; const ll mod = 1000000007; const ll INF = (ll)1000000007 * 1000000007; typedef pair P; #define stop char nyaa;cin>>nyaa; #define rep(i,n) for(int i=0;i=0;i--) #define Rep(i,sta,n) for(int i=sta;i=sta;i--) #define rep1(i,n) for(int i=1;i<=n;i++) #define per1(i,n) for(int i=n;i>=1;i--) #define Rep1(i,sta,n) for(int i=sta;i<=n;i++) typedef long double ld; typedef complex Point; const ld eps = 1e-8; const ld pi = acos(-1.0); typedef pair LP; vector prime_list(int l,int r){//[l,r]に含まれる素数表 vector li(r+1,1); for(int i=2;i<=r;i++){ if (!li[i]) continue; for(int j=2*i;j<=r;j+=i){ li[j]=0; } } vector res={}; for(int i=max(2,l);i<=r;i++){ if (li[i]) res.push_back(i); } return res; } vector div(int s,vector V){ int m=V.size(); vector res(m,0); if(s==0){ rep(i,m){ res[i]=-1000; } return res; } rep(i,m){ while(s%V[i]==0){ res[i]++; s/=V[i]; } } if(s!=1){ rep(i,m){ res[i]=1000; } return res; } return res; } int n,a[100010],q; vector A[100010],S[100010]; void solve(){ cin >> n; vector P=prime_list(0,n); S[0].resize(P.size(),0); rep(i,n){ S[i+1].resize(P.size(),0); cin >> a[i]; A[i]=div(a[i],P); rep(k,P.size()){ S[i+1][k]=S[i][k]+A[i][k]; } } cin >> q; rep(i,q){ int p,l,r;cin >> p >> l >> r; vector R=div(p,P); vector T(P.size(),0); bool flag=true; rep(k,P.size()){ T[k]=S[r][k]-S[l][k]; if(R[k]>T[k]){ flag=false; break; } } if(flag) cout << "Yes" << endl; else cout << "NO" << endl; } } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(50); solve(); }