Min Value

robin_aust STP Coding Test 31 Dec 20...
Limits 1s, 512 MB

You are given an array of NN integers and q queries. In each query you are given an integer value xx. For each xx you have to choose a value from the given array. Let, this value be yy. Now your task is to find the minimum value of zz. Where,

z=max(x,y)min(x,y)z = max(x, y) - min(x, y)

max(x,y)max(x, y) means maximum value between xx and yy.

min(x,y)min(x, y) means minimum value between xx and yy.

Input

First line contains two integers NN (1N1051 ≤ N ≤ 10^5) and qq (1q1051 ≤ q ≤ 10^5). The next line contains NN space separated integers, aia_i (0ai1090 ≤ a_i ≤ 10^9), forming this array. Next qq lines will contain the value of xx (0x1090 ≤ x ≤ 10^9).

Output

For each xx you have to print a line containing the minimum value of zz.

Sample

InputOutput
5 2
2 1 6 4 5
1
3
0
1

Submit

Login to submit.

Contributors

Statistics

65% Solution Ratio
Debasish161017Earliest, Dec '20
steinumFastest, 0.0s
steinumLightest, 5.5 kB
shreasShortest, 520B
Toph uses cookies. By continuing you agree to our Cookie Policy.