import heapq

n,m = list(map(int, input().split(' ')))



# I am given n pieces

if n >= m:

	print(0)

else:

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

	xis.sort()





	distances = [v- u for u,v in zip(xis,xis[1:])]

	distances.sort(key = lambda x:-x)

	print(sum(distances[n-1:] or [0]))
import heapq

n,m = list(map(int, input().split(' ')))



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

xis.sort()

distances = [v- u for u,v in zip(xis,xis[1:])]

distances.sort(key = lambda x:-x)

print(sum(distances[n-1:] or [0]))
import heapq

n, m = list(map(int, input().split(" ")))
# I am given n pieces
if n >= m:
    print(0)
else:
    xis = list(map(int, input().split()))
    xis.sort()
    distances = [v - u for u, v in zip(xis, xis[1:])]
    distances.sort(key=lambda x: -x)
    print(sum(distances[n - 1 :] or [0]))

import heapq

n, m = list(map(int, input().split(" ")))
xis = list(map(int, input().split()))
xis.sort()
distances = [v - u for u, v in zip(xis, xis[1:])]
distances.sort(key=lambda x: -x)
print(sum(distances[n - 1 :] or [0]))

-# I am given n pieces -if n >= m: -    print(0) -else: -    xis = list(map(int, input().split())) -    xis.sort() -    distances = [v - u for u, v in zip(xis, xis[1:])] -    distances.sort(key=lambda x: -x) -    print(sum(distances[n - 1 :] or [0])) +xis = list(map(int, input().split())) +xis.sort() +distances = [v - u for u, v in zip(xis, xis[1:])] +distances.sort(key=lambda x: -x) +print(sum(distances[n - 1 :] or [0]))