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

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

X.sort()

diff = []

if M != 1:

  for i in range(M-1):

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

else:

  diff = [0]



sorted_diff = sorted(diff)

sorted_diff.reverse()



ans = sum(sorted_diff)

for i in range(min([N,M])-1):

  ans -= sorted_diff[i]

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

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

X.sort()

d = []

for i in range(M-1):

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

d.sort()

if M-N >= 0:

  print((sum(d[0:M-N])))

else:

  print((0))
N, M = list(map(int, input().split()))
X = list(map(int, input().split()))
X.sort()
diff = []
if M != 1:
    for i in range(M - 1):
        diff.append(X[i + 1] - X[i])
else:
    diff = [0]
sorted_diff = sorted(diff)
sorted_diff.reverse()
ans = sum(sorted_diff)
for i in range(min([N, M]) - 1):
    ans -= sorted_diff[i]
print(ans)

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

-diff = [] -if M != 1: -    for i in range(M - 1): -        diff.append(X[i + 1] - X[i]) +d = [] +for i in range(M - 1): +    d.append(X[i + 1] - X[i]) +d.sort() +if M - N >= 0: +    print((sum(d[0 : M - N]))) -    diff = [0] -sorted_diff = sorted(diff) -sorted_diff.reverse() -ans = sum(sorted_diff) -for i in range(min([N, M]) - 1): -    ans -= sorted_diff[i] -print(ans) +    print((0))