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

lst = []

for i in range(N):

    x = int(eval(input()))

    lst.append(x)

lst.sort()

L = []

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

    L.append(lst[i + K -1] - lst[i])

L.sort()

print((L[0]))
N, K = list(map(int, input().split()))

lst = []

for i in range(N):

    lst.append(int(eval(input())))

lst.sort()

dif = 10**9

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

    if lst[i+K-1] - lst[i] < dif:

        dif = lst[i+K-1] - lst[i]

print(dif)
N, K = list(map(int, input().split()))
lst = []
for i in range(N):
    x = int(eval(input()))
    lst.append(x)
lst.sort()
L = []
for i in range(N - K + 1):
    L.append(lst[i + K - 1] - lst[i])
L.sort()
print((L[0]))

N, K = list(map(int, input().split()))
lst = []
for i in range(N):
    lst.append(int(eval(input())))
lst.sort()
dif = 10**9
for i in range(N - K + 1):
    if lst[i + K - 1] - lst[i] < dif:
        dif = lst[i + K - 1] - lst[i]
print(dif)

-    x = int(eval(input())) -    lst.append(x) +    lst.append(int(eval(input()))) -L = [] +dif = 10**9 -    L.append(lst[i + K - 1] - lst[i]) -L.sort() -print((L[0])) +    if lst[i + K - 1] - lst[i] < dif: +        dif = lst[i + K - 1] - lst[i] +print(dif)