import sys from array import array input = sys.stdin.buffer.readline def primes(n): is_prime = [True] * (n + 1) is_prime[0] = False is_prime[1] = False for i in range(2, int(n ** 0.5) + 1): if not is_prime[i]: continue for j in range(i * 2, n + 1, i): is_prime[j] = False return (i for i in range(n + 1) if is_prime[i]) N = int(input()) A = tuple(map(int, input().split())) Q = int(input()) queries = [(map(int, input().split())) for _ in range(Q)] MAX = max(max(A), 1) P = tuple(primes(MAX)) L = len(P) acc_list = [array('I', [0] * (N + 1)) for _ in range(L)] INF = 10 ** 7 for i, a in enumerate(A, 1): if a: temp = a for x, pr in enumerate(P): ct = 0 while not temp % pr: temp //= pr ct += 1 acc_list[x][i] = ct else: for p in range(L): acc_list[p][i] = INF for p in range(L): for i in range(N): acc_list[p][i + 1] += acc_list[p][i] for p, l, r in queries: temp = p for x, pr in enumerate(P): ct = 0 while not temp % pr: temp //= pr ct += 1 diff = acc_list[x][r] - acc_list[x][l - 1] if diff >= INF: print('Yes') break elif diff < ct: print('NO') break else: print('Yes' if temp == 1 else 'NO')