You are given an array of integers and q queries. In each query you are given an integer value . For each you have to choose a value from the given array. Let, this value be . Now your task is to find the minimum value of . Where,
means maximum value between and .
means minimum value between and .
First line contains two integers () and (). The next line contains space separated integers, (), forming this array. Next lines will contain the value of ().
For each you have to print a line containing the minimum value of .
Input | Output |
---|---|
5 2 2 1 6 4 5 1 3 | 0 1 |