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

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

H.sort()

import numpy as np

H=np.array(H)

print(((H[K-1:]-H[:-K+1]).min()))

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

import numpy as np

H=np.array([int(eval(input())) for _ in range(N)])

H.sort()

print(((H[K-1:]-H[:-K+1]).min()))

N, K = list(map(int, input().split()))
H = [int(eval(input())) for _ in range(N)]
H.sort()
import numpy as np

H = np.array(H)
print(((H[K - 1 :] - H[: -K + 1]).min()))

N, K = list(map(int, input().split()))
import numpy as np

H = np.array([int(eval(input())) for _ in range(N)])
H.sort()
print(((H[K - 1 :] - H[: -K + 1]).min()))

-H = [int(eval(input())) for _ in range(N)] -H.sort() -H = np.array(H) +H = np.array([int(eval(input())) for _ in range(N)]) +H.sort()