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

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

ans = float("inf")

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

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

print(ans)

N, K, *H = list(map(int, open(0).read().split()))

H.sort()

a = float('inf')

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

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

print(a)
N, K = list(map(int, input().split()))
h = sorted([int(eval(input())) for _ in range(N)])
ans = float("inf")
for i in range(N - K + 1):
    ans = min(ans, h[i + K - 1] - h[i])
print(ans)

N, K, *H = list(map(int, open(0).read().split()))
H.sort()
a = float("inf")
for i in range(N - K + 1):
    a = min(a, H[i + K - 1] - H[i])
print(a)

-N, K = list(map(int, input().split())) -h = sorted([int(eval(input())) for _ in range(N)]) -ans = float("inf") +N, K, *H = list(map(int, open(0).read().split())) +H.sort() +a = float("inf") -    ans = min(ans, h[i + K - 1] - h[i]) -print(ans) +    a = min(a, H[i + K - 1] - H[i]) +print(a)