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

h=[]

for i in range(n):

    h.append(int(eval(input())))

h.sort()

ans=10**10

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

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

    ans=min(t,ans)

print(ans)

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

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

h.sort()

ans=10**18

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

  ans=min(h[i+k-1]-h[i],ans)

print(ans)



n, k = list(map(int, input().split()))
h = []
for i in range(n):
    h.append(int(eval(input())))
h.sort()
ans = 10**10
for i in range(n - k + 1):
    t = h[i + k - 1] - h[i]
    ans = min(t, ans)
print(ans)

n, k = list(map(int, input().split()))
h = [int(eval(input())) for i in range(n)]
h.sort()
ans = 10**18
for i in range(n - k + 1):
    ans = min(h[i + k - 1] - h[i], ans)
print(ans)

-h = [] -for i in range(n): -    h.append(int(eval(input()))) +h = [int(eval(input())) for i in range(n)] -ans = 10**10 +ans = 10**18 -    t = h[i + k - 1] - h[i] -    ans = min(t, ans) +    ans = min(h[i + k - 1] - h[i], ans)