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

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

if n>=m:

    r=0

else:

    L=[]

    for i in range(m-1):

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

        L.append(l)

    L.sort(reverse=True)

    r=X[-1]-X[0]

    for j in range(n-1):

        r-=L[j]

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

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

L=sorted([X[i+1]-X[i] for i in range(m-1)])

if n>=m:

    print((0))

else:

    print((sum(L)-sum([L[-i-1] for i in range(n-1)])))
n, m = list(map(int, input().split()))
X = sorted(map(int, input().split()))
if n >= m:
    r = 0
else:
    L = []
    for i in range(m - 1):
        l = X[i + 1] - X[i]
        L.append(l)
    L.sort(reverse=True)
    r = X[-1] - X[0]
    for j in range(n - 1):
        r -= L[j]
print(r)

n, m = list(map(int, input().split()))
X = sorted(map(int, input().split()))
L = sorted([X[i + 1] - X[i] for i in range(m - 1)])
if n >= m:
    print((0))
else:
    print((sum(L) - sum([L[-i - 1] for i in range(n - 1)])))

+L = sorted([X[i + 1] - X[i] for i in range(m - 1)]) -    r = 0 +    print((0)) -    L = [] -    for i in range(m - 1): -        l = X[i + 1] - X[i] -        L.append(l) -    L.sort(reverse=True) -    r = X[-1] - X[0] -    for j in range(n - 1): -        r -= L[j] -print(r) +    print((sum(L) - sum([L[-i - 1] for i in range(n - 1)])))