Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/minmax-23-x-ga-eng-yaqin-son

Number closest to X

Easy 1000 ms 128 MB 31%
Share

A positive integer $N$, an integer $X$ and $N$ integers are given. Find the number of the sequence closest to $X$, that is, the $A_{i}$ with the smallest $|A_{i} - X|$, and its position (indexed from $1$). If there are several such numbers, take the first one.

Finding the element closest to a given number

Input

The first line contains two integers: $N$ and $X$. The next line contains $N$ integers $A_{i}$.

Output

One line with two integers separated by a space: the number closest to $X$ and its position.

Note

$1 \le N \le 1000$
$-10^{9} \le A_{i} \le 10^{9}$
$-10^{9} \le X \le 10^{9}$

Examples

Input #1
5 6
2 9 4 8 13
Output #1
4 3
Input #2
4 5
7 3 5 6
Output #2
5 3

Sign in to submit a solution

Signing up is free and takes a minute.