#include using namespace std; 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); int n; cin >> n; vector primes; vector > trees; for (int i = 1; i <= 2000; i++) { if (isprime(i)) { primes.push_back(i); auto plus = [](short a, short b) { return min(100, a + b); }; trees.push_back(SegTree(n, 0, plus)); } } for (int i = 0; i < n; i++) { int a; cin >> a; for (int j = 0; j < primes.size(); j++) { int c = 0; while (a % primes[j] == 0) { a /= primes[j]; ++c; } trees[j].update(i, c); } } string ret; int q; cin >> q; for (int i = 0; i < q; i++) { int x, l, r; cin >> x >> l >> r; bool ck = true; for (int j = 0; j < primes.size(); j++) { int c = 0; while (x % primes[j] == 0) { ++c; x /= primes[j]; } if (c > trees[j].query(l-1, r)) { ck = false; break; } } ck &= x == 1; if (ck) ret += "Yes\n"; else ret += "NO\n"; } cout << ret << endl; return 0; }