#K14751. Journey Through Tunnels

    ID: 24204 Type: Default 1000ms 256MiB

Journey Through Tunnels

Journey Through Tunnels

You are given n tunnels with specific power levels. Starting at station 0, you want to determine if you can reach a given destination station y using these tunnels. The journey is considered possible if there exists at least one tunnel with power p such that the destination station id y is a multiple of p (i.e., \(y \bmod p = 0\)).

More formally, you are given an integer \(n\), followed by a list of \(n\) positive integers representing the power levels of the tunnels. Then, you are given an integer \(k\) representing the number of queries, followed by \(k\) integers, each indicating a destination station id. For each query, output "YES" if there exists at least one tunnel power \(p\) such that \(y \bmod p = 0\), otherwise output "NO".

Note: The input and output will be processed via standard input (stdin) and standard output (stdout) respectively.

inputFormat

The first line contains an integer \(n\) representing the number of tunnels.

The second line contains \(n\) space-separated positive integers representing the power levels of the tunnels.

The third line contains an integer \(k\) representing the number of destination queries.

The following \(k\) lines each contain a single integer \(y\), the destination station id to check.

outputFormat

For each destination query, output a line containing either "YES" if it is possible to reach that station, or "NO" if it is not.

## sample
3
2 3 5
3
4
6
7
YES

YES NO

</p>