#!/usr/bin/env python3.8 # %% import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np N = int(readline()) A = np.array(readline().split(), np.int32) Q = int(readline()) PLR = np.array(read().split(), np.int32) P = PLR[::3] L = PLR[1::3] R = PLR[2::3] U = 2010 is_prime = np.zeros(U, np.bool) is_prime[2] = 1 is_prime[3::2] = 1 for p in range(3, U, 2): if p * p >= U: break if is_prime[p]: is_prime[p * p::p + p] = 0 primes = np.where(is_prime)[0].tolist() A_nonzero = (A != 0) def calc_ord(A, p): ord_A = np.zeros_like(A) while True: q, r = np.divmod(A, p) divisible = r == 0 & (A_nonzero) if not np.any(divisible): return ord_A ord_A[divisible] += 1 A[divisible] = q[divisible] def solve(p): ord_A = calc_ord(A, p) ord_P = calc_ord(P, p) cum = np.zeros(len(ord_A) + 1, np.int32) cum[1:] = np.cumsum(ord_A) x = cum[R] - cum[L - 1] return x >= ord_P ok = np.ones(Q, np.bool) for p in primes[:5]: ok &= solve(p) ok &= (P == 1) answer = np.where(ok, 'Yes', 'NO') print('\n'.join(answer))