def min_processing_time(n: int, k: int, contrasts: List[int]) -> int:
    """
    Evlampiy has found one more cool application to process photos. However the application has certain limitations.
    
    Each photo i has a contrast v_{i}. In order for the processing to be truly of high quality, the application must receive at least k photos with contrasts which differ as little as possible.
    
    Evlampiy already knows the contrast v_{i} for each of his n photos. Now he wants to split the photos into groups, so that each group contains at least k photos. As a result, each photo must belong to exactly one group.
    
    He considers a processing time of the j-th group to be the difference between the maximum and minimum values of v_{i} in the group. Because of multithreading the processing time of a division into groups is the maximum processing time among all groups.
    
    Split n photos into groups in a such way that the processing time of the division is the minimum possible, i.e. that the the maximum processing time over all groups as least as possible.
    
    
    -----Input-----
    
    The first line contains two integers n and k (1 ≤ k ≤ n ≤ 3·10^5) — number of photos and minimum size of a group.
    
    The second line contains n integers v_1, v_2, ..., v_{n} (1 ≤ v_{i} ≤ 10^9), where v_{i} is the contrast of the i-th photo.
    
    
    -----Output-----
    
    Print the minimal processing time of the division into groups.
    
    
    -----Examples-----
    Input
    5 2
    50 110 130 40 120
    
    Output
    20
    
    Input
    4 1
    2 3 4 1
    
    Output
    0
    
    
    
    -----Note-----
    
    In the first example the photos should be split into 2 groups: [40, 50] and [110, 120, 130]. The processing time of the first group is 10, and the processing time of the second group is 20. Maximum among 10 and 20 is 20. It is impossible to split the photos into groups in a such way that the processing time of division is less than 20.
    
    In the second example the photos should be split into four groups, each containing one photo. So the minimal possible processing time of a division is 0.
    """


# Tests

def check(candidate):
    assert min_processing_time(5, 2, [50, 110, 130, 40, 120]) == 20
    assert min_processing_time(4, 1, [2, 3, 4, 1]) == 0
    assert min_processing_time(1, 1, [4]) == 0
    assert min_processing_time(2, 2, [7, 5]) == 2
    assert candidate(3, 2, [34, 3, 75]) == 72
    assert min_processing_time(5, 2, [932, 328, 886, 96, 589]) == 343
    assert min_processing_time(10, 4, [810, 8527, 9736, 3143, 2341, 6029, 7474, 707, 2513, 2023]) == 3707
    assert min_processing_time(20, 11, [924129, 939902, 178964, 918687, 720767, 695035, 577430, 407131, 213304, 810868, 596349, 266075, 123602, 376312, 36680, 18426, 716200, 121546, 61834, 851586]) == 921476
    assert min_processing_time(100, 28, [1, 2, 3, 5, 1, 1, 1, 4, 1, 5, 2, 4, 3, 2, 5, 4, 1, 1, 4, 1, 4, 5, 4, 1, 4, 5, 1, 3, 5, 1, 1, 1, 4, 2, 5, 2, 3, 5, 2, 2, 3, 2, 4, 5, 5, 5, 5, 1, 2, 4, 1, 3, 1, 1, 1, 4, 3, 1, 5, 2, 5, 1, 3, 3, 2, 4, 5, 1, 1, 3, 4, 1, 1, 3, 3, 1, 2, 4, 3, 3, 4, 4, 3, 1, 2, 1, 5, 1, 4, 4, 2, 3, 1, 3, 3, 4, 2, 4, 1, 1]) == 1
    assert min_processing_time(101, 9, [3, 2, 2, 1, 4, 1, 3, 2, 3, 4, 3, 2, 3, 1, 4, 4, 1, 1, 4, 1, 3, 3, 4, 1, 2, 1, 1, 3, 1, 2, 2, 4, 3, 1, 4, 3, 1, 1, 4, 4, 1, 2, 1, 1, 4, 2, 3, 4, 1, 2, 1, 4, 4, 1, 4, 3, 1, 4, 2, 1, 2, 1, 4, 3, 4, 3, 4, 2, 2, 4, 3, 2, 1, 3, 4, 3, 2, 2, 4, 3, 3, 2, 4, 1, 3, 2, 2, 4, 1, 3, 4, 2, 1, 3, 3, 2, 2, 1, 1, 3, 1]) == 0
    assert min_processing_time(2, 2, [1, 1000000000]) == 999999999
    assert min_processing_time(2, 1, [1, 1000000000]) == 0
    assert min_processing_time(11, 3, [412, 3306, 3390, 2290, 1534, 316, 1080, 2860, 253, 230, 3166]) == 1122
    assert min_processing_time(10, 3, [2414, 294, 184, 666, 2706, 1999, 2201, 1270, 904, 653]) == 707
    assert min_processing_time(24, 4, [33, 27, 12, 65, 19, 6, 46, 33, 57, 2, 21, 50, 73, 13, 59, 69, 51, 45, 39, 1, 6, 64, 39, 27]) == 9
check(min_processing_time)