import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] sa = br.readLine().split(" "); int n = Integer.parseInt(sa[0]); sa = br.readLine().split(" "); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = Integer.parseInt(sa[i]); } sa = br.readLine().split(" "); int q = Integer.parseInt(sa[0]); int[][] p = new int[q][3]; for (int i = 0; i < q; i++) { sa = br.readLine().split(" "); for (int j = 0; j < 3; j++) { p[i][j] = Integer.parseInt(sa[j]); } } br.close(); List> list = new ArrayList<>(n); list.add(new HashMap<>()); for (int i = 0; i < n; i++) { Map soinsu = bunkai(a[i]); for (Integer o : list.get(i).keySet()) { if (soinsu.containsKey(o)) { soinsu.put(o, soinsu.get(o) + list.get(i).get(o)); } else { soinsu.put(o, list.get(i).get(o)); } } list.add(soinsu); } PrintWriter pw = new PrintWriter(System.out); for (int i = 0; i < q; i++) { Map soinsu = bunkai(p[i][0]); Map l = list.get(p[i][1] - 1); Map r = list.get(p[i][2]); boolean flg = true; for (Integer o : soinsu.keySet()) { int x = soinsu.get(o); Integer y = l.get(o); if (y == null) y = 0; Integer z = r.get(o); if (z == null) z = 0; if (x > z - y) { flg = false; break; } } if (flg) { pw.println("Yes"); } else { pw.println("NO"); } } pw.flush(); } static Map bunkai(int n) { Map soinsu = new HashMap<>(); int end = (int) Math.sqrt(n); int d = 2; while (n > 1) { if (n % d == 0) { n /= d; if (soinsu.containsKey(d)) { soinsu.put(d, soinsu.get(d) + 1); } else { soinsu.put(d, 1); } end = (int) Math.sqrt(n); } else { if (d > end) { d = n - 1; } d++; } } return soinsu; } }