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

~/algor $ cat problems/qidiruv-k-chi-ayirma

k-th pair difference

Hard 2000 ms 128 MB 81%
Share

An array $a$ of $n$ integers is given. For each pair $i \lt j$ the difference $|a_{i} - a_{j}|$ is written down ($\frac{n(n-1)}{2}$ numbers in total). Which number is in the $k$-th place when these numbers are sorted in non-decreasing order?

Points on the number line and all differences between them; the k-th among the sorted differences is highlighted

Input

The first line contains two positive integers: $n$ and $k$.
The second line contains $n$ integers $a_{i}$.

Output

One integer.

Note

$2 \le n \le 2 \cdot 10^{4}$
$1 \le k \le \frac{n(n-1)}{2}$
$0 \le a_{i} \le 10^{9}$

Examples

Input #1
4 3
1 6 3 10
Output #1
4
Input #2
2 1
5 5
Output #2
0

Sign in to submit a solution

Signing up is free and takes a minute.