#include #define rep(i, n) for (int i = 0; i < (n); i++) #define repr(i, n) for (int i = (n) - 1; i >= 0; i--) using namespace std; using ll = long long; int main() { int n; cin >> n; vector a(n); rep(i, n) cin >> a[i]; vector table(2001, true); vector primes; for (int i = 2; i <= 2000; i++) { if (table[i]) { primes.push_back(i); for (int j = i + i; j <= 2000; j += i) { table[j] = false; } } } int q; cin >> q; vector p(q), l(q), r(q); rep(i, q) cin >> p[i] >> l[i] >> r[i], l[i]--; vector sum(n+1); vector zero(n+1); rep(i, n) { zero[i + 1] = zero[i] + (a[i] == 0); } vector ans(q, true); for (int prime : primes) { fill(sum.begin(), sum.end(), 0); rep(i, n) { sum[i + 1] = sum[i]; while (a[i] != 0 && a[i] % prime == 0) { a[i] /= prime; sum[i + 1]++; } } rep(i, q) { if (zero[r[i]] - zero[l[i]] > 0) continue; int k = 0; while (p[i] % prime == 0) { p[i] /= prime; k++; } if (sum[r[i]] - sum[l[i]] < k) { ans[i] = false; } } } rep(i, q) if (p[i] != 1 && zero[r[i]] - zero[l[i]] == 0) ans[i] = false; rep(i, q) { cout << (ans[i] ? "Yes" : "NO") << '\n'; } }