let read_line () = stdin.ReadLine() let read_tokens () = read_line().Split ' ' let N = read_line () |> int let A = read_tokens () |> Array.map int let Q = read_line () |> int let P = Array.zeroCreate Q let L = Array.zeroCreate Q let R = Array.zeroCreate Q let zero = Array.zeroCreate (N+1) for i in 0..Q-1 do let p, l, r = read_tokens () |> (fun a -> int a.[0], int a.[1], int a.[2]) P.[i] <- p L.[i] <- l - 1 R.[i] <- r for i in 0..N-1 do zero.[i+1] <- zero.[i] + (if A.[i] = 0 then 1 else 0) for i in 0..Q-1 do if zero.[R.[i]] - zero.[L.[i]] > 0 then P.[i] <- 1 let table = Array.create 2001 true let primes = new ResizeArray() table.[0] <- false table.[1] <- false for i in 2..10 do if table.[i] then primes.Add(i) for j in 2*i..i..2000 do table.[j] <- false let ans = Array.create Q true for p in primes do let cnt = Array.zeroCreate (N+1) for i in 0..N-1 do let mutable k = 0 while A.[i] <> 0 && A.[i] % p = 0 do A.[i] <- A.[i] / p k <- k + 1 cnt.[i+1] <- cnt.[i] + k for i in 0..Q-1 do let mutable k = 0 while P.[i] % p = 0 do P.[i] <- P.[i] / p k <- k + 1 if cnt.[R.[i]] - cnt.[L.[i]] < k then ans.[i] <- false for i in 0..Q-1 do if P.[i] <> 1 then ans.[i] <- false printfn "%s" (if ans.[i] then "Yes" else "NO")