#include using vi = std::vector; using vvi = std::vector; int N; vvi smallPrime, largePrime; vi primeTable, zeroCount; void makePrimeTable() { std::vector isPrime(2'001, true); for (int i{2}; i <= 2'000; i++) { if (!isPrime[i]) continue; primeTable.push_back(i); if (i <= 100) smallPrime.push_back(vi(N + 1)); else largePrime.push_back({}); for (int j{2 * i}; j <= 2'000; j += i) isPrime[j] = false; } } bool dividable() { int64_t P; int L, R; scanf("%lld%d%d", &P, &L, &R); L--; for (int p_i{}; p_i < (int)smallPrime.size() && P > 1; p_i++) { int count{}; while (P % primeTable[p_i] == 0) { P /= primeTable[p_i]; count++; } if (count > smallPrime[p_i][R] - smallPrime[p_i][L]) return false; } if (P == 1) return true; for (int p_i{}; p_i < (int)largePrime.size() && P > 1; p_i++) { int count{}; while (P % primeTable[smallPrime.size() + p_i] == 0) { P /= primeTable[smallPrime.size() + p_i]; count++; } if (count > 0 && std::upper_bound(largePrime[p_i].begin(), largePrime[p_i].end(), R) - std::lower_bound(largePrime[p_i].begin(), largePrime[p_i].end(), L + 1) < count ) return false; } return P == 1; } int main() { scanf("%d", &N); makePrimeTable(); zeroCount.resize(N + 1); for (int n_i{1}; n_i <= N; n_i++) { int A; scanf("%d", &A); zeroCount[n_i] += zeroCount[n_i - 1]; if (A == 0) { zeroCount[n_i]++; continue; } for (int p_i{}; p_i < (int)smallPrime.size(); p_i++) { while (A % primeTable[p_i] == 0) { A /= primeTable[p_i]; smallPrime[p_i][n_i]++; } smallPrime[p_i][n_i] += smallPrime[p_i][n_i - 1]; } for (int p_i{}; p_i < (int)largePrime.size(); p_i++) if (A % primeTable[smallPrime.size() + p_i] == 0) largePrime[p_i].push_back(n_i); } int Q; scanf("%d", &Q); for (int i{}; i < Q; i++) if (dividable()) puts("Yes"); else puts("NO"); return 0; }