#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using i64 = int64_t; using i32 = int32_t; template void init_n(vector& v, size_t n, U x) { v = vector(n, x); } template void init_n(vector& v, size_t n) { init_n(v, n, T()); } template void read_n(vector& v, size_t n, size_t o = 0) { v = vector(n+o); for (size_t i=o; i> v[i]; } template void read_n(T a[], size_t n, size_t o = 0) { for (size_t i=o; i> a[i]; } template T gabs(const T& x) { return max(x, -x); } #define abs gabs template> struct Fenwick { i64 n; vector c; F f; Fenwick(i64 n, F f = plus(), T init = T()) : n(n), c(n + 1, init), f(f) {} T sum(i64 i) { return i > 0 ? f(sum(i - (i & -i)), c[i]) : T(); } void add(i64 i, i64 x) { if (i <= n) { c[i] = f(c[i], x); add(i + (i & -i), x); } } }; template Fenwick make_fenwick(i64 n, F f, T init = T()) { return Fenwick(n, f, init); } i64 n; // 315,000,000 vector> fs; int main() { cin >> n; init_n(fs, 100001, make_fenwick(n, plus(), (unsigned short)0)); for (i64 i = 1; i <= n; ++i) { i64 a; cin >> a; for (i64 x = 2; x <= 330; ++x) { while (a % x == 0) { fs[x].add(i, 1); a /= x; } } if (a > 1) fs[a].add(i, 1); } i64 q; cin >> q; while (q--) { i64 p, l, r; cin >> p >> l >> r; if (p == 1) { cout << "Yes\n"; continue; } map mp; for (int x = 2; x <= 330; ++x) { while (p % x == 0) { mp[x]++; p /= x; } } if (p > 1) mp[p]++; bool ok = true; for (auto e : mp) { i64 x = e.first, c = e.second; i64 s = fs[x].sum(r) - fs[x].sum(l - 1); if (c > s) ok = false; } cout << (ok ? "Yes" : "NO") << '\n'; } return 0; }