#73Easy
Element closest to R
Time: 1 s · Memory: 256 MB
- Arrays
Statement
You are given an array of numbers and a number . Find the element closest to , i.e. with the smallest . If there are several, print the first of them.
Input format
The first line contains and (, ). The second line contains integers ().
Output format
A single number — the element found.
Examples
Input
8 5 1 3 2 4 6 7 9 1
Output
4
Input
3 10 4 16 12
Output
12
Note
Compute the distance with an absolute value: abs(a[i] - R). To keep the first one on ties, update only on a strictly smaller distance (<, not <=). In the second example and are both at distance , but is at distance : the answer is .
