n, k = list(map(int, input().split()))

h = sorted([int(eval(input())) for _ in range(n)])

min_diff = 10**9

for i in range(n - k + 1):

    min_diff = min(min_diff, h[i + k - 1] - h[i])

print(min_diff)
n, k = list(map(int, input().split()))

h = sorted([int(eval(input())) for _ in range(n)])

print((min(h[i + k - 1] - h[i] for i in range(n - k + 1))))
n, k = list(map(int, input().split()))
h = sorted([int(eval(input())) for _ in range(n)])
min_diff = 10**9
for i in range(n - k + 1):
    min_diff = min(min_diff, h[i + k - 1] - h[i])
print(min_diff)

n, k = list(map(int, input().split()))
h = sorted([int(eval(input())) for _ in range(n)])
print((min(h[i + k - 1] - h[i] for i in range(n - k + 1))))

-min_diff = 10**9 -for i in range(n - k + 1): -    min_diff = min(min_diff, h[i + k - 1] - h[i]) -print(min_diff) +print((min(h[i + k - 1] - h[i] for i in range(n - k + 1))))