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



a = [int(eval(input())) for _ in range(n)]

a.sort()

b = 0

ans = []



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

    b = a[i + k - 1] - a[i]

    ans.append(b)

ans.sort()

print((ans[0]))
n, k = list(map(int, input().split()))

a = [int(eval(input())) for _ in range(n)]

a.sort()



ans = []

 

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

    b = a[i + k - 1] - a[i]

    ans.append(b)



print((min(ans)))
n, k = list(map(int, input().split()))
a = [int(eval(input())) for _ in range(n)]
a.sort()
b = 0
ans = []
for i in range(n - k + 1):
    b = a[i + k - 1] - a[i]
    ans.append(b)
ans.sort()
print((ans[0]))

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

-b = 0 -ans.sort() -print((ans[0])) +print((min(ans)))