#T91. 查找最接近的元素

查找最接近的元素

Description

In a non-descending sequence, find the element closest to a given value.

Input Format

The first line contains an integer n, representing the length of the non-descending sequence. 1 ≤ n ≤ 100000.
The second line contains n integers, representing the elements of the non-descending sequence. All elements are within the range of 0-1,000,000,000.
The third line contains an integer m, representing the number of queries for given values. 1 ≤ m ≤ 10000.
The following m lines each contain an integer, representing the given value for which the closest element is to be found. All given values are within the range of 0-1,000,000,000.

Output Format

Output m lines, each containing an integer representing the element value closest to the corresponding given value, maintaining the input order. If multiple values satisfy the condition, output the smallest one.

3
2 5 8
2
10
5

8
5