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

H = sorted([int(eval(input())) for n in range(N)])

a = 1e+9



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

  a = min(a,H[n+K-1]-H[n])



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

H = sorted([int(eval(input())) for n in range(N)])

A = []



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

  A+=[H[n+K-1]-H[n]]



print((min(A)))
N, K = list(map(int, input().split()))
H = sorted([int(eval(input())) for n in range(N)])
a = 1e9
for n in range(N - K + 1):
    a = min(a, H[n + K - 1] - H[n])
print(a)

N, K = list(map(int, input().split()))
H = sorted([int(eval(input())) for n in range(N)])
A = []
for n in range(N - K + 1):
    A += [H[n + K - 1] - H[n]]
print((min(A)))

-a = 1e9 +A = [] -    a = min(a, H[n + K - 1] - H[n]) -print(a) +    A += [H[n + K - 1] - H[n]] +print((min(A)))