import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); ArrayList> apples = new ArrayList<>(); apples.add(new HashMap<>()); for (int i = 0; i < n; i++) { HashMap tmp = new HashMap(apples.get(i)); int x = sc.nextInt(); for (int j = 2; j <= Math.sqrt(x); j++) { while (x % j == 0) { tmp.put(j, tmp.getOrDefault(j, 0) + 1); x /= j; } } if (x > 1) { tmp.put(x, tmp.getOrDefault(x, 0) + 1); } apples.add(tmp); } int q = sc.nextInt(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < q; i++) { int p = sc.nextInt(); HashMap left = apples.get(sc.nextInt() - 1); HashMap right = apples.get(sc.nextInt()); boolean can = true; for (int j = 2; j <= Math.sqrt(p) && can; j++) { if (p % j > 0) { continue; } int count = right.getOrDefault(j, 0) - left.getOrDefault(j, 0); while (p % j == 0) { count--; p /= j; } can = (count >= 0); } if (can && p > 1) { can = (right.getOrDefault(p, 0) - left.getOrDefault(p, 0) >= 1); } if (can) { sb.append("Yes"); } else { sb.append("NO"); } sb.append("\n"); } System.out.print(sb); } }