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

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

diff = [0] * (M - 1)

for i in range(M - 1):

    diff[i] = X[i + 1] - X[i]

print((sum(sorted(diff)[: max(0, M - N)])))

N, M, *X = list(map(int, open(0).read().split()))



if N >= M:

    print((0))

    exit()



X.sort()

diff = []

for i in range(M - 1):

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

diff.sort()

print((sum(diff[: M - N])))



N, M = list(map(int, input().split()))
X = sorted(map(int, input().split()))
diff = [0] * (M - 1)
for i in range(M - 1):
    diff[i] = X[i + 1] - X[i]
print((sum(sorted(diff)[: max(0, M - N)])))

N, M, *X = list(map(int, open(0).read().split()))
if N >= M:
    print((0))
    exit()
X.sort()
diff = []
for i in range(M - 1):
    diff.append(X[i + 1] - X[i])
diff.sort()
print((sum(diff[: M - N])))

-N, M = list(map(int, input().split())) -X = sorted(map(int, input().split())) -diff = [0] * (M - 1) +N, M, *X = list(map(int, open(0).read().split())) +if N >= M: +    print((0)) +    exit() +X.sort() +diff = [] -    diff[i] = X[i + 1] - X[i] -print((sum(sorted(diff)[: max(0, M - N)]))) +    diff.append(X[i + 1] - X[i]) +diff.sort() +print((sum(diff[: M - N])))