#include using namespace std; class factor { vector p; public: factor() : p(vector(303)) {} factor(vector p): p(p) {} int get(int i) const { return p[i]; } }; const factor ZERO = factor(); factor operator+(const factor &a, const factor &b) { vector c(303); for (int i = 0; i < 303; i++) c[i] = a.get(i) + b.get(i); return factor(c); } template class SegTree { int n; vector seg; T nil; function binop; void update(int k, int l, int r, int p, T x) { if (p < l || r <= p) return; if (r - l == 1) seg[k] = x; else { update(2*k+1, l, (l+r)/2, p, x); update(2*k+2, (l+r)/2, r, p, x); seg[k] = binop(seg[2*k+1], seg[2*k+2]); } } T query(int k, int l, int r, int a, int b) { if (b <= l || r <= a) return nil; if (a <= l && r <= b) return seg[k]; return binop(query(2*k+1, l, (l+r)/2, a, b), query(2*k+2, (l+r)/2, r, a, b)); } public: SegTree(int n, T nil, function binop): n(n), seg(4*n), nil(nil), binop(binop) {} void init() { for (int i = 0; i < 4*n; i++) seg[i] = nil; } // update p-th value to x void update(int p, T x) { update(0, 0, n, p, x); } // query for range [l, r) T query(int l, int r) { return query(0, 0, n, l, r); } }; bool isprime(long long n) { if (n < 2) return false; if (n == 2) return true; if (n % 2 == 0) return false; for (long long i = 3; i * i <= n; i += 2) if (n % i == 0) return false; return true; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); vector primes; for (int i = 1; i <= 2000; i++) if (isprime(i)) primes.push_back(i); int n; cin >> n; function plus = [] (factor a, factor b) { return a + b; }; SegTree tree(n, ZERO, plus); for (int i = 0; i < n; i++) { int a; cin >> a; vector p(303); for (int j = 0; j < 303; j++) { while (a % primes[j] == 0) { a /= primes[j]; ++p[j]; } } tree.update(i, factor(p)); } int q; cin >> q; for (int i = 0; i < q; i++) { long long p; int l, r; cin >> p >> l >> r; factor x = tree.query(l-1, r); bool ck = true; for (int j = 0; j < 303; j++) { int c = 0; while (p % primes[j] == 0) { ++c; p /= primes[j]; } if (c > x.get(j)) { ck = false; break; } } if (ck) cout << "Yes" << endl; else cout << "NO" << endl; } return 0; }