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

~/algor $ cat problems/qidiruv-eng-katta-minimal-masofa

Largest minimum distance

Medium 1000 ms 128 MB 62%
Share

There are $n$ posts on a line, the $i$-th post is at point $p_{i}$. $k$ guards must be placed at different posts so that the distance between the two closest guards is as large as possible. Find the largest value of this distance.

Posts on the number line: the posts with guards and the smallest distance between neighbours are highlighted

Input

The first line contains two positive integers: $n$ and $k$. The second line contains $n$ distinct integers $p_{i}$ separated by spaces (in any order).

Output

One integer — the largest value of the distance between the two closest guards.

Note

$2 \le k \le n \le 10^{5}$
$0 \le p_{i} \le 10^{9}$, all $p_{i}$ are distinct

Examples

Input #1
5 3
1 2 8 4 9
Output #1
3
Input #2
4 2
10 1 5 7
Output #2
9

Sign in to submit a solution

Signing up is free and takes a minute.