#include #include using namespace std; using namespace atcoder; using ll = long long; using P = pair; using mint = modint1000000007; #define rep(i, n) for (int i = 0; i < (int)(n); i++) vector Sieve(int n) { vector lst(n + 1, 1); vector temp; for (int i = 2; i <= n; i++) { if (lst[i]) { for (int j = 2 * i; j <= n; j += i) { lst[j] = 0; } } } for (int i = 2; i <= n; i++){ temp.push_back(i); } return temp; } int main() { int N; cin >> N; vector A(N); rep(i, N) cin >> A[i]; vector Prime = Sieve(2000); int M = (int)Prime.size(); vector> D(M, vector(N, 0)); vector> Dc(M + 1, vector(N, 0)); rep(i, M){ rep(j, N){ while (A[j] % Prime[i] == 0){ A[j] /= Prime[i]; D[i][j]++; } } rep(j, N){ Dc[i][j + 1] = Dc[i][j] + D[i][j]; } } int Q; cin >> Q; rep(_, Q){ int P, L, R; int flag = 1; cin >> P >> L >> R; L--; rep(i, M){ int cnt = 0; while (P % Prime[i] == 0){ cnt++; P /= Prime[i]; } if (cnt > Dc[i][R] - Dc[i][L]){ cout << "NO" << "\n"; flag = 0; break; } } if (flag){ cout << "Yes" << "\n"; } } }