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



H = []

for i in range(N):

    H.append(int(eval(input())))



H.sort()

ans = 10**9

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

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



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

T = [int(eval(input())) for i in range(N)]



T.sort()

P = []

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

    P.append(T[i+K-1] - T[i])



print((min(P)))
N, K = list(map(int, input().split()))
H = []
for i in range(N):
    H.append(int(eval(input())))
H.sort()
ans = 10**9
for i in range(N - K + 1):
    ans = min(ans, H[i + K - 1] - H[i])
print(ans)

N, K = list(map(int, input().split()))
T = [int(eval(input())) for i in range(N)]
T.sort()
P = []
for i in range(N - K + 1):
    P.append(T[i + K - 1] - T[i])
print((min(P)))

-H = [] -for i in range(N): -    H.append(int(eval(input()))) -H.sort() -ans = 10**9 +T = [int(eval(input())) for i in range(N)] +T.sort() +P = [] -    ans = min(ans, H[i + K - 1] - H[i]) -print(ans) +    P.append(T[i + K - 1] - T[i]) +print((min(P)))