import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); boolean[] isNotPrime = new boolean[2000]; int size = 0; for (int i = 2; i < 2000; i++) { if (!isNotPrime[i]) { size++; for (int j = 2; j * i < 2000; j++) { isNotPrime[j * i] = true; } } } int[] primes = new int[size]; int idx = 0; for (int i = 2; i < 2000; i++) { if (!isNotPrime[i]) { primes[idx] = i; idx++; } } int[][] counts = new int[n + 1][size]; for (int i = 0; i < n; i++) { int x = sc.nextInt(); for (int j = 0; j < size; j++) { counts[i + 1][j] = counts[i][j]; while (x % primes[j] == 0) { counts[i + 1][j]++; x /= primes[j]; } } } 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(); boolean can = true; for (int j = 0; j < size && p > 1; j++) { int limit = counts[right][j] - counts[left][j]; for (int k = 0; k < limit; k++) { if (p % primes[j] == 0) { p /= primes[j]; } else { break; } } } if (p == 1) { sb.append("Yes"); } else { sb.append("NO"); } sb.append("\n"); } System.out.print(sb); } }