#include #define FOR(i,k,n) for(int i = (k);i < (n);++i) #define REP(i,n) FOR(i,0,n) #define ALL(x) begin(x),end(x) using namespace std; using vecint = vector; using ll = int64_t; vecint pl(int n) { vector b(n+1, true); b[0] = b[1] = false; for (int i = 2; i*i <= n; ++i) if (b[i]) for (int j = i*i; j <= n; j += i) b[j] = false; vecint res; REP(i,n+1) if (b[i]) res.push_back(i); return res; } int main() { int n; cin>>n; vector v(303, vecint(n+1, 0)); auto pp = pl(2000); int np = pp.size(); REP(i,n) { int b; cin>>b; REP(j,np) { v[j][i+1] = v[j][i]; while ((b % pp[j]) == 0) { b /= pp[j]; ++v[j][i+1]; } } } int q; cin>>q; REP(i,q) { int p,l,r; cin>>p>>l>>r; REP(j,303) { int d = v[j][r] - v[j][l-1]; REP(k,d) { if ((p % pp[j]) == 0) { p /= pp[j]; } else { break; } } } if (p == 1) { cout << "Yes" << endl; } else { cout << "NO" << endl; } } return 0; }