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

h = list(int(eval(input())) for _ in range(N))

h.sort()



i = 0

ans = 10 ** 9

while i + K - 1 < N:

  n = abs(h[i+K-1] - h[i])

  if ans > n: ans = n

  i += 1

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

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

h.sort()

ans = 10 ** 9

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

    if h[i+k-1] - h[i] < ans:

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

print(ans)
N, K = list(map(int, input().split()))
h = list(int(eval(input())) for _ in range(N))
h.sort()
i = 0
ans = 10**9
while i + K - 1 < N:
    n = abs(h[i + K - 1] - h[i])
    if ans > n:
        ans = n
    i += 1
print(ans)

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

-N, K = list(map(int, input().split())) -h = list(int(eval(input())) for _ in range(N)) +n, k = list(map(int, input().split())) +h = [int(eval(input())) for _ in range(n)] -i = 0 -while i + K - 1 < N: -    n = abs(h[i + K - 1] - h[i]) -    if ans > n: -        ans = n -    i += 1 +for i in range(n - k + 1): +    if h[i + k - 1] - h[i] < ans: +        ans = h[i + k - 1] - h[i]