#pragma GCC optimize ("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC target ("avx") #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using Int = long long; template ostream &operator<<(ostream &os, const pair &a) { return os << "(" << a.first << ", " << a.second << ")"; }; template void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; } template void chmin(T &t, const T &f) { if (t > f) t = f; } template void chmax(T &t, const T &f) { if (t < f) t = f; } constexpr int LIM = 2005; bool isnp[100010]; int primesLen; int primes[320]; int N; int A[100010]; int Q; int M[100010], L[100010], R[100010]; int sums[320][100010]; int main() { for (int p = 2; p < LIM; ++p) { if (!isnp[p]) { for (int n = 2 * p; n < LIM; n += p) { isnp[n] = true; } } } for (int p = 2; p < LIM; ++p) { if (!isnp[p]) { primes[primesLen++] = p; } } cerr << "|primes| = " << primesLen << endl; for (; ~scanf("%d", &N); ) { for (int i = 0; i < N; ++i) { scanf("%d", &A[i]); } scanf("%d", &Q); for (int q = 0; q < Q; ++q) { scanf("%d%d%d", &M[q], &L[q], &R[q]); --L[q]; } for (int h = 0; h < primesLen; ++h) { const int p = primes[h]; for (int i = 0; i < N; ++i) { int e = 0; for (int a = A[i]; a % p == 0; a /= p) { ++e; } sums[h][i + 1] = sums[h][i] + e; } } for (int q = 0; q < Q; ++q) { bool ans = true; int m = M[q]; for (int h = 0; h < primesLen; ++h) { const int p = primes[h]; int e = 0; for (; m % p == 0; m /= p) { ++e; } ans = ans && (sums[h][R[q]] - sums[h][L[q]] >= e); } ans = ans && (m == 1); puts(ans ? "Yes" : "NO"); } } return 0; }