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

l=sorted(int(eval(input())) for _ in [0]*n)

print((min(l[i+k-1]-l[i] for i in range(n-k+1))))
n,k,*l=list(map(int,open(0).read().split()))

l.sort()

print((min(l[k+i-1]-l[i] for i in range(n-k+1))))
n, k = list(map(int, input().split()))
l = sorted(int(eval(input())) for _ in [0] * n)
print((min(l[i + k - 1] - l[i] for i in range(n - k + 1))))

n, k, *l = list(map(int, open(0).read().split()))
l.sort()
print((min(l[k + i - 1] - l[i] for i in range(n - k + 1))))

-n, k = list(map(int, input().split())) -l = sorted(int(eval(input())) for _ in [0] * n) -print((min(l[i + k - 1] - l[i] for i in range(n - k + 1)))) +n, k, *l = list(map(int, open(0).read().split())) +l.sort() +print((min(l[k + i - 1] - l[i] for i in range(n - k + 1))))