PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#BS0000326. Lực từ giữa các quả bóng (Magnetic Force Between Two Balls)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Lực từ giữa các quả bóng (Magnetic Force Between Two Balls)

Magnetic Force Between Two Balls

Source: LeetCode

Version: Phuoc Hung OJ Extended

Problem Statement

Rick has nn empty baskets on a line, with basket ii at the distinct integer coordinate aia_i. Morty must place exactly kk balls, at most one in each basket.

The magnetic force between balls at xx and yy is defined as ∣x−y∣|x-y|. For a placement, consider the smallest force among all pairs of balls.

Choose baskets to maximize that smallest force.

Input

The first line contains two integers n,kn,k, the numbers of baskets and balls.

The second line contains nn integers a1,…,ana_1,\ldots,a_n, the basket coordinates.

Output

Print one integer: the maximum achievable minimum magnetic force.

Subtasks

  • Subtask 1 (20 points): 2≤k≤n≤122\le k\le n\le12; 1≤ai≤1091\le a_i\le10^9; ai≠aj (i≠j)a_i\ne a_j\ (i\ne j).
  • Subtask 2 (30 points): 2≤k≤n≤1052\le k\le n\le10^5; 1≤ai≤1091\le a_i\le10^9; ai≠aj (i≠j)a_i\ne a_j\ (i\ne j); k=2k=2.
  • Subtask 3 (50 points): 2≤k≤n≤1052\le k\le n\le10^5; 1≤ai≤1091\le a_i\le10^9; ai≠aj (i≠j)a_i\ne a_j\ (i\ne j).

Examples

Input 1

5 3
1 2 3 4 7

Output 1

3

Explanation

Use baskets at 1, 4 and 7. The forces are 3, 3 and 6, so the minimum is 3. Three balls with minimum gap 4 would need a span of at least 8, but the available span is only 6.

Example 1

Input 2

6 2
5 4 3 2 1 1000000000

Output 2

999999999

Explanation

Use coordinates 1 and 10910^9. Their difference is 999999999999999999, the entire available span, so no larger force is possible.