#define _USE_MATH_DEFINES #include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define MT make_tuple #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)<; using vi = vector; using vll = vector; vector sieve(int n) { vector f(n + 1); for (int i = 3; i <= n; i += 2) f[i] = 1; for (int i = 3; i <= sqrt(n); i += 2) if (f[i]) for (int j = i * 3; j <= n; j += i) f[j] = 0; vector res; if (n >= 2)res.push_back(2); for (int i = 3; i <= n; i += 2) if (f[i]) res.push_back(i); return res; } void solve() { vi primes = sieve(2000); // 303個 int N; cin >> N; vi A(N); rep(i, N)cin >> A[i]; int Q; cin >> Q; vi P(Q), L(Q), R(Q); vector ans(Q); rep(i, Q) { cin >> P[i] >> L[i] >> R[i]; --L[i]; } vi x(N + 1); rep(i, N)if (A[i] == 0)x[i + 1]++; rep(i, N)x[i + 1] += x[i]; rep(i, Q)if ( x[R[i]]-x[L[i]] > 0) { ans[i] = true; } each(prime, primes) { fill(all(x), 0); rep(i, N) { if (A[i] == 0)continue; int cnt = 0; while (A[i] % prime == 0) { cnt++; A[i] /= prime; } x[i + 1] = cnt; } rep(i, N)x[i + 1] += x[i]; rep(i, Q) { int y = x[R[i]] - x[L[i]]; for (int j = 0; j < y && P[i] % prime == 0; ++j) { P[i] /= prime; } if (P[i] == 1) { ans[i] = true; } } } rep(i, Q) { cout << (ans[i] ? "Yes" : "NO") << endl; } } int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15); solve(); return 0; }