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

hlist = [int(eval(input())) for _ in range(N)]

hlist.sort(reverse=True)

sa = []



for _ in range(N-K+1):

    num = hlist[_]-hlist[_+(K-1)]

    sa.append(num)

sa.sort()

print((sa[0]))

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

hlist = sorted([int(eval(input())) for _ in range(N)])

ans = 10**9 + 7

for i in range(N - K + 1):

    ans = min(ans, hlist[i + K - 1] - hlist[i])

print(ans)

N, K = list(map(int, input().split()))
hlist = [int(eval(input())) for _ in range(N)]
hlist.sort(reverse=True)
sa = []
for _ in range(N - K + 1):
    num = hlist[_] - hlist[_ + (K - 1)]
    sa.append(num)
sa.sort()
print((sa[0]))

N, K = list(map(int, input().split()))
hlist = sorted([int(eval(input())) for _ in range(N)])
ans = 10**9 + 7
for i in range(N - K + 1):
    ans = min(ans, hlist[i + K - 1] - hlist[i])
print(ans)

-hlist = [int(eval(input())) for _ in range(N)] -hlist.sort(reverse=True) -sa = [] -for _ in range(N - K + 1): -    num = hlist[_] - hlist[_ + (K - 1)] -    sa.append(num) -sa.sort() -print((sa[0])) +hlist = sorted([int(eval(input())) for _ in range(N)]) +ans = 10**9 + 7 +for i in range(N - K + 1): +    ans = min(ans, hlist[i + K - 1] - hlist[i]) +print(ans)