N, K = list(map(int, input().split()))

h_list = [None] * N

for n in range(N):

    h_list[n] = int(eval(input()))



h_list = list(sorted(h_list))



min_diff = 10 ** 10

for i in range(N):

    if K - 1 + i >= N:

        break

    diff = h_list[K - 1 + i] - h_list[i]

    if diff < min_diff:

        min_diff = diff

print(min_diff)
N, K = list(map(int, input().split()))

h_list = [None] * N

for n in range(N):

    h_list[n] = int(eval(input()))



h_list = list(sorted(h_list))



print((min(h_list[K - 1 + i] - h_list[i] for i in range(N - K + 1))))
N, K = list(map(int, input().split()))
h_list = [None] * N
for n in range(N):
    h_list[n] = int(eval(input()))
h_list = list(sorted(h_list))
min_diff = 10**10
for i in range(N):
    if K - 1 + i >= N:
        break
    diff = h_list[K - 1 + i] - h_list[i]
    if diff < min_diff:
        min_diff = diff
print(min_diff)

N, K = list(map(int, input().split()))
h_list = [None] * N
for n in range(N):
    h_list[n] = int(eval(input()))
h_list = list(sorted(h_list))
print((min(h_list[K - 1 + i] - h_list[i] for i in range(N - K + 1))))

-min_diff = 10**10 -for i in range(N): -    if K - 1 + i >= N: -        break -    diff = h_list[K - 1 + i] - h_list[i] -    if diff < min_diff: -        min_diff = diff -print(min_diff) +print((min(h_list[K - 1 + i] - h_list[i] for i in range(N - K + 1))))