import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); HashMap[] maps = new HashMap[n + 1]; maps[0] = new HashMap<>(); for (int i = 1; i <= n; i++) { maps[i] =(HashMap)(maps[i - 1].clone()); int x = sc.nextInt(); for (int j = 2; j <= Math.sqrt(x); j++) { while (x % j == 0) { if (maps[i].containsKey(j)) { maps[i].put(j, maps[i].get(j) + 1); } else { maps[i].put(j, 1); } x /= j; } } if (x > 1) { if (maps[i].containsKey(x)) { maps[i].put(x, maps[i].get(x) + 1); } else { maps[i].put(x, 1); } } } int q = sc.nextInt(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < q; i++) { int p = sc.nextInt(); int left = sc.nextInt() - 1; int right = sc.nextInt() - 1; HashMap target = (HashMap)(maps[right].clone()); for (Map.Entry entry : maps[left - 1].entrySet()) { target.put(entry.getKey(), target.get(entry.getKey()) - entry.getValue()); } boolean flag = true; for (int j = 2; j <= Math.sqrt(p) && flag; j++) { while (p % j == 0 && flag) { if (target.containsKey(j)) { int x = target.get(j); x--; if (x < 0) { flag = false; } else { target.put(j, x); } } else { flag = false; } p /= j; } } if (flag && p > 1) { if (target.containsKey(p)) { int x = target.get(p); x--; if (x < 0) { flag = false; } } else { flag = false; } } if (flag) { sb.append("Yes"); } else { sb.append("NO"); } sb.append("\n"); } System.out.print(sb); } }