#P9064. Minimum Sound Difference

    ID: 22223 Type: Default 1000ms 256MiB

Minimum Sound Difference

Minimum Sound Difference

You are given n wind chimes hanging from a roof, numbered from 1 to n from left to right. The i-th wind chime produces a tone of pitch ai.

In order to express his feelings, Fusu decides to select m out of these n wind chimes as a gift for a distant friend. Let the pitches of the selected chimes be b1, b2, ..., bm. Your task is to find the minimum integer \(\varepsilon\) such that there exists a selection with the property that for any \(1 \le i, j \le m\), it holds that \(|b_i - b_j| \le \varepsilon\>.

Note: In other words, if \(\varepsilon\) is the range of the chosen pitches, i.e., \(\varepsilon = \max(b) - \min(b)\), then find the minimum possible \(\varepsilon\) over all choices of m chimes.

Input and output format details are provided below.

inputFormat

The first line contains two integers n and m (mn).

The second line contains n integers, representing the pitches \(a_1, a_2, ..., a_n\).

outputFormat

Output the minimum integer \(\varepsilon\) satisfying the described property.

sample

5 3
10 1 2 4 8
3