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

#if N >= M:

#  print(0)

#  exit()

  

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



X.sort()

diff = []



for i in range(1,M):

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



diff.sort()



for i in range(N - 1):

  if len(diff) != 0:

    diff.pop()



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

X = [int(i) for i in input().split()]

if N >= M:

  print((0))

  exit()



X.sort()

dist = []

for i in range(M-1):

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

dist.sort()



ans = 0

for i in range(M-N):

  ans += dist[i]

print(ans)

N, M = list(map(int, input().split()))
# if N >= M:
#  print(0)
#  exit()
X = list(map(int, input().split()))
X.sort()
diff = []
for i in range(1, M):
    diff.append(X[i] - X[i - 1])
diff.sort()
for i in range(N - 1):
    if len(diff) != 0:
        diff.pop()
print((sum(diff)))

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

-# if N >= M: -#  print(0) -#  exit() -X = list(map(int, input().split())) +X = [int(i) for i in input().split()] +if N >= M: +    print((0)) +    exit() -diff = [] -for i in range(1, M): -    diff.append(X[i] - X[i - 1]) -diff.sort() -for i in range(N - 1): -    if len(diff) != 0: -        diff.pop() -print((sum(diff))) +dist = [] +for i in range(M - 1): +    dist.append(X[i + 1] - X[i]) +dist.sort() +ans = 0 +for i in range(M - N): +    ans += dist[i] +print(ans)