import math n = int(input()) a = list(map(int, input().split())) m = 2000 k = int(math.sqrt(10 ** 9)) dp = [None for _ in range(k + 1)] idx = {} for x in range(2, k + 1): if not dp[x] is None: continue dp[x] = x if x <= m: idx[x] = len(idx) for y in range(2 * x, k + 1, x): if not dp[y] is None: continue dp[y] = x s = [[0 for _ in range(n + 1)] for _ in range(len(idx))] for i in range(n): cur = a[i] while cur > 1: s[idx[dp[cur]]][i + 1] += 1 cur //= dp[cur] zero = [0 for _ in range(n + 1)] for i in range(n): zero[i + 1] = zero[i] if a[i] == 0: zero[i + 1] += 1 for i in range(len(idx)): for j in range(1, n + 1): s[i][j] += s[i][j - 1] q = int(input()) ans = [None for _ in range(q)] for i in range(q): p, l, r = map(int, input().split()) l -= 1 r -= 1 if p == 1 or zero[r + 1] - zero[l] > 0: ans[i] = "Yes" continue cnt = {} cur = p flg = True for x in range(2, k + 1): if cur == 1: break if dp[x] != x or cur % x != 0: continue if x > m: flg = False break y = idx[x] cnt[y] = 0 while cur % x == 0: cnt[y] += 1 cur //= x if not flg or cur > 1: ans[i] = "NO" continue if any(s[x][r + 1] - s[x][l] < v for x, v in cnt.items()): ans[i] = "NO" else: ans[i] = "Yes" print(*ans, sep="\n")