s=input().split(' ')

n=int(s[0])

k=int(s[1])



ar=[]

for i in range(0,n):

	j=int(eval(input()))

	ar.append(j)



ar.sort()

i=0; j=k-1;

mn=100000000000

while j<n:

	if ar[j]-ar[i]<mn:

		mn=ar[j]-ar[i]

	j+=1; i+=1;

print(mn);


s=input().split();

n=int(s[0])

k=int(s[1])



lt=[]*n;

for i in range(0,n):

	a=int(input())

	lt.append(a)

lt.sort()

mx=1000000000000000

i=0; j=k-1;

while j<n:

	l=lt[j]-lt[i]

	j+=1;

	i+=1;

	if l<mx:

		mx=l;

print(mx)
s = input().split(" ")
n = int(s[0])
k = int(s[1])
ar = []
for i in range(0, n):
    j = int(eval(input()))
    ar.append(j)
ar.sort()
i = 0
j = k - 1
mn = 100000000000
while j < n:
    if ar[j] - ar[i] < mn:
        mn = ar[j] - ar[i]
    j += 1
    i += 1
print(mn)

s = input().split()
n = int(s[0])
k = int(s[1])
lt = [] * n
for i in range(0, n):
    a = int(input())
    lt.append(a)
lt.sort()
mx = 1000000000000000
i = 0
j = k - 1
while j < n:
    l = lt[j] - lt[i]
    j += 1
    i += 1
    if l < mx:
        mx = l
print(mx)

-s = input().split(" ") +s = input().split() -ar = [] +lt = [] * n -    j = int(eval(input())) -    ar.append(j) -ar.sort() +    a = int(input()) +    lt.append(a) +lt.sort() +mx = 1000000000000000 -mn = 100000000000 -    if ar[j] - ar[i] < mn: -        mn = ar[j] - ar[i] +    l = lt[j] - lt[i] -print(mn) +    if l < mx: +        mx = l +print(mx)