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]); 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++) { sa = br.readLine().split(" "); int p0 = Integer.parseInt(sa[0]); int p1 = Integer.parseInt(sa[1]); int p2 = Integer.parseInt(sa[2]); if (p0 == 1) { pw.println("Yes"); continue; } Map soinsu = bunkai(p0); Map l = list.get(p1 - 1); Map r = list.get(p2); 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; } }