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

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

ans = h[k-1]-h[0]

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

    m = h[i+k-1]-h[i]

    ans = min(m,ans)

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

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

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

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

-ans = h[k - 1] - h[0] -for i in range(n - k + 1): -    m = h[i + k - 1] - h[i] -    ans = min(m, ans) -print(ans) +print((min(h[j + k - 1] - h[j] for j in range(n - k + 1))))