#include "bits/stdc++.h" using namespace std; #define Rep(i,n) for(int i=0;i<(int)(n);i++) #define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++) #define REP(i,n) for(ll i=0;i<(ll)(n);i++) #define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--) #define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++) #define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--) #define put(a) cout< P; template inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; } template inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; } template T upsum(const T& l, const T& r) {//SegmentTreeのupdate関数 T res; res = l + r; return res; } template class SegmentTree { public: using F = function; vector seg; int sz = 1; T unit; F up; //T (*up)(const T& l,const T& r); SegmentTree(int n, F up, T unit = 0) { this->unit = unit; //int sz = 1; while (sz < n) sz <<= 1; seg.resize(sz * 2, unit); this->up = up; } void set(const int& k, const T& x) {//左からk番目の葉にxを代入する seg[sz - 1 + k] = x; } T get(const int& k) {//左からk番目の葉を得る return seg[sz - 1 + k]; } void update(int k, const T& v) {// k 番目の値をvに変更 k += sz - 1; seg[k] = v; while (k > 0) { k = (k - 1) / 2; seg[k] = up(seg[2 * k + 1], seg[2 * k + 2]); } } T query(int a, int b, int k, int l, int r) {//[a,b)のupの合成を求める(a,b,0,0,sz)のように使う if (r <= a || b <= l) { return unit; } if (a <= l && r <= b) { return seg[k]; } else { T vl = query(a, b, k * 2 + 1, l, (l + r) / 2); T vr = query(a, b, k * 2 + 2, (l + r) / 2, r); return up(vl, vr); } } }; int main() { int n; cin >> n; vector a(n); REP(i, n)cin >> a[i]; int q; cin >> q; vector p(q), l(q), r(q); REP(i, q)cin >> p[i] >> l[i] >> r[i]; vector prime; FOR(i,2, 2001) { bool flag = true; for (int j = 2; j * j <= i; ++j) { if (i % j == 0)flag = false; } if (flag) { prime.push_back(i); } } vector> sg(prime.size(), SegmentTree(n, upsum, 0)); //SegmentTree sgmax(n, upsum, -1); int m = prime.size(); REP(i, n) { int k = a[i]; for (int j = 0; j < m;) { if (k % prime[j] == 0) { ll t = sg[j].get(i); sg[j].update(i,t + 1); k /= prime[j]; } else { j++; } if (k == 1) { break; } } } int sz = sg[0].sz; REP(i, q) { vector ps(m, 0); REP(j, m) { ps[j] = sg[j].query(l[i]-1, r[i], 0, 0, sz); } vector pt(m, 0); int k = p[i]; for (int j = 0; j < m;) { if (k % prime[j] == 0) { pt[j]++; k /= prime[j]; } else { j++; } if (k == 1) { break; } } if (k != 1) { put("NO"); return 0; } bool flag = true; REP(j, m) { if (ps[i] < pt[i]) { flag = false; } } if (flag) { put("YES"); } else { put("NO"); } } return 0; }