LogiQuest

174. Aggressive Cows

HardBinary Search on Answer

Place c cows in c of the n stalls (positions given) to maximise the minimum distance between any two cows. Print that distance.

Input format

Line 1: n c Line 2: n stall positions

Output format

The largest possible minimum distance.

Example 1

Input

5 3
1 2 8 4 9

Output

3

Example 2

Input

3 2
1 2 3

Output

2

Constraints

2 ≤ c ≤ n ≤ 10⁵ 0 ≤ positions ≤ 10⁹

Read input from standard input and print the answer to standard output. Your code is judged against 5 test cases, most of them hidden.

Loading the MyLoginn IDE…