MOD = 10 ** 9 + 7 INF = 10 ** 11 def sieve(n): if n == 1:return [] primes = [1 if i%2 == 1 else 0 for i in range(n + 1)] primes[1] = 0 primes[2] = 1 for i in range(3,n + 1,2): if i * i > n: break if primes[i]: for j in range(i * i,n + 1,i): primes[j] = 0 return [p for p in range(2,n + 1) if primes[p] == 1] def factorization(n,primes): factor = {p:0 for p in primes} for p in primes: while n%p == 0: n //= p factor[p] += 1 if n != 1: factor[n] = 1 return factor def main(): N = int(input()) primes = sieve(20005) A = list(map(int,input().split())) A = [{p:0 for p in primes}] + [factorization(a,primes) for a in A] for i in range(N): for p in primes: A[i + 1][p] += A[i][p] Q = int(input()) for _ in range(Q): M,l,r = map(int,input().split()) for p in primes: divisor = A[r][p] - A[l - 1][p] while M%p == 0 and divisor > 0: M //= p if M%p == 0: break if M > 1: print('NO') else: print('Yes') if __name__ == '__main__': main()