Final exam is coming. To review the math, teacher gives you a difficult problem.
Teacher will give you n integers and an integer m. You should answer the maximum k satisfying
. If such k does not exist, please answer -1.
Now this problem becomes more difficult. You should process Q queries of m to the same sequence of n and .
The first line contains an integer
.
The second line contains n integers.
The third line contains an integerdenoting the count of query.
Following Q lines each line contains an integer.
For each query, output a line containing the answer for the maxinum k.