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



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

X.sort()



Y = []



for i in range(N - 1):

    Y.append((i, X[i + 1] - X[i]))

Y.sort(key=lambda y: y[1], reverse=True)

Y = Y[:M - 1]

Y.sort(key=lambda y: y[0])



p = 0

c = 0

for i, y in Y:

    c += X[i] - X[p]

    p = i + 1

c += X[-1] - X[p]



print(c)

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



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

X.sort()



Y = []



for i in range(N - 1):

    Y.append(X[i + 1] - X[i])



Y.sort()



if M < N:

    c = X[-1] - X[0] - sum(Y[N - M:])

else:

    c = 0



print(c)

M, N = list(map(int, input().split()))
X = list(map(int, input().split()))
X.sort()
Y = []
for i in range(N - 1):
    Y.append((i, X[i + 1] - X[i]))
Y.sort(key=lambda y: y[1], reverse=True)
Y = Y[: M - 1]
Y.sort(key=lambda y: y[0])
p = 0
c = 0
for i, y in Y:
    c += X[i] - X[p]
    p = i + 1
c += X[-1] - X[p]
print(c)

M, N = list(map(int, input().split()))
X = list(map(int, input().split()))
X.sort()
Y = []
for i in range(N - 1):
    Y.append(X[i + 1] - X[i])
Y.sort()
if M < N:
    c = X[-1] - X[0] - sum(Y[N - M :])
else:
    c = 0
print(c)

-    Y.append((i, X[i + 1] - X[i])) -Y.sort(key=lambda y: y[1], reverse=True) -Y = Y[: M - 1] -Y.sort(key=lambda y: y[0]) -p = 0 -c = 0 -for i, y in Y: -    c += X[i] - X[p] -    p = i + 1 -c += X[-1] - X[p] +    Y.append(X[i + 1] - X[i]) +Y.sort() +if M < N: +    c = X[-1] - X[0] - sum(Y[N - M :]) +else: +    c = 0