# Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

# Smallest Interval

Alice has a collection of **N** numbers. She would like to place them on a number line. She places each of the **N** numbers on the point corresponding to its value on the number line. Now she wonders, what’s the size of the smallest interval on the number line such that there are at least **K** numbers from her collection on that interval?

## Input

The first line of the input contains two integers **N** and **K**. The next line consists of **N** space separated integers denoting Alice’s numbers. Let, a_{i} be the i^{th} number on this line.

#### Constraints:

1 ≤ N ≤ 10^{5}

1 ≤ K ≤ N

1 ≤ a_{i} ≤ 10^{9}

## Output

In a single line, print the size of the smallest interval on the number line where at least **K** integers from Alice’s collection can be found.

## Samples

Input | Output |
---|---|

5 3 17 12 5 4 8 | 4 |

Input | Output |
---|---|

6 2 16 5 7 4 4 8 | 0 |

Explanation of Sample Case 1: The desired interval is [4,8] which contains 4, 5 and 8. The size of this interval is 4.

Explanation of Sample Case 2: The desired interval is [4,4] which contains 4 and 4. The size of this interval is 0.

#### Sherlock221b

Imran is a part-time philosopher who enjoys solving programming problems, climbing mountains and sports. →

Login to submit