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

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

a.sort(reverse=True)



if n >= m:

    print((0))

    exit()



b = []

for i in range(m-1):

    b.append(abs(a[i+1]-a[i]))

b.sort(reverse=True)



for i in range(n-1):

    b.pop(0)



print((sum(b)))
n,m = list(map(int,input().split()))

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

a.sort(reverse=True)



if n >= m:

    print((0))

    exit()



b = []

for i in range(m-1):

    b.append(abs(a[i+1]-a[i]))



b.sort()

print((sum(b[:m-n])))
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort(reverse=True)
if n >= m:
    print((0))
    exit()
b = []
for i in range(m - 1):
    b.append(abs(a[i + 1] - a[i]))
b.sort(reverse=True)
for i in range(n - 1):
    b.pop(0)
print((sum(b)))

n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort(reverse=True)
if n >= m:
    print((0))
    exit()
b = []
for i in range(m - 1):
    b.append(abs(a[i + 1] - a[i]))
b.sort()
print((sum(b[: m - n])))

-b.sort(reverse=True) -for i in range(n - 1): -    b.pop(0) -print((sum(b))) +b.sort() +print((sum(b[: m - n])))