# -*- coding: utf-8 -*-



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

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

X.sort()



if N >= M:

    print((0))

    exit()



diffX = [X[i + 1] - X[i] for i in range(len(X) - 1)]

diffX.sort()



ans = X[-1] - X[0]

for i in range(N - 1):

    ans -= diffX[-(i + 1)]



print(ans)

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

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

D = sorted([X[i + 1] - X[i] for i in range(M - 1)])

print((X[-1] - X[0] - sum(D[-(N - 1):]) if N > 1 else X[-1] - X[0]))

# -*- coding: utf-8 -*-
N, M = list(map(int, input().split()))
X = list(map(int, input().split()))
X.sort()
if N >= M:
    print((0))
    exit()
diffX = [X[i + 1] - X[i] for i in range(len(X) - 1)]
diffX.sort()
ans = X[-1] - X[0]
for i in range(N - 1):
    ans -= diffX[-(i + 1)]
print(ans)

N, M = list(map(int, input().split()))
X = sorted(list(map(int, input().split())))
D = sorted([X[i + 1] - X[i] for i in range(M - 1)])
print((X[-1] - X[0] - sum(D[-(N - 1) :]) if N > 1 else X[-1] - X[0]))

-# -*- coding: utf-8 -*- -X = list(map(int, input().split())) -X.sort() -if N >= M: -    print((0)) -    exit() -diffX = [X[i + 1] - X[i] for i in range(len(X) - 1)] -diffX.sort() -ans = X[-1] - X[0] -for i in range(N - 1): -    ans -= diffX[-(i + 1)] -print(ans) +X = sorted(list(map(int, input().split()))) +D = sorted([X[i + 1] - X[i] for i in range(M - 1)]) +print((X[-1] - X[0] - sum(D[-(N - 1) :]) if N > 1 else X[-1] - X[0]))