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

X = list(map(int, input().split()))

X.sort()

L = []



for i in reversed(list(range(len(X)))):

    if i - 1 < 0:

        break

    if (X[i] >= 0 and X[i-1] >= 0) or (X[i] <= 0 and X[i-1] <= 0):

        L.append(abs(X[i] - X[i-1]))

    else:

        L.append(abs(X[i]) + abs(X[i-1]))



L.sort()

L_min = 0

for i in range(M-N):

    L_min += L[i]



print(L_min)

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

X = list(map(int, input().split()))

X.sort()

L = [0] * (M-1)



for i in range(M-1):

    L[i] = abs(X[i+1] - X[i])



L.sort()



print((sum(L[:-(N-1)]) if N != 1 else sum(L)))

N, M = list(map(int, input().split()))
X = list(map(int, input().split()))
X.sort()
L = []
for i in reversed(list(range(len(X)))):
    if i - 1 < 0:
        break
    if (X[i] >= 0 and X[i - 1] >= 0) or (X[i] <= 0 and X[i - 1] <= 0):
        L.append(abs(X[i] - X[i - 1]))
    else:
        L.append(abs(X[i]) + abs(X[i - 1]))
L.sort()
L_min = 0
for i in range(M - N):
    L_min += L[i]
print(L_min)

N, M = list(map(int, input().split()))
X = list(map(int, input().split()))
X.sort()
L = [0] * (M - 1)
for i in range(M - 1):
    L[i] = abs(X[i + 1] - X[i])
L.sort()
print((sum(L[: -(N - 1)]) if N != 1 else sum(L)))

-L = [] -for i in reversed(list(range(len(X)))): -    if i - 1 < 0: -        break -    if (X[i] >= 0 and X[i - 1] >= 0) or (X[i] <= 0 and X[i - 1] <= 0): -        L.append(abs(X[i] - X[i - 1])) -    else: -        L.append(abs(X[i]) + abs(X[i - 1])) +L = [0] * (M - 1) +for i in range(M - 1): +    L[i] = abs(X[i + 1] - X[i]) -L_min = 0 -for i in range(M - N): -    L_min += L[i] -print(L_min) +print((sum(L[: -(N - 1)]) if N != 1 else sum(L)))