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

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

d = [0]*(m-1)

k.sort()

for i in range(m-1):

    d[i] = abs(k[i]-k[i+1])

d = sorted(d, reverse=True)

res = 0

for i in range(n-1):

    if i==m-1:

        break

    res += d[i]

print((sum(d)-res))

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

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

d = [0]*(m-1)

k.sort()

for i in range(m-1):

    d[i] = abs(k[i]-k[i+1])

d = sorted(d, reverse=True)

print((sum(d)-sum(d[:n-1])))

n, m = list(map(int, input().split()))
k = list(map(int, input().split()))
d = [0] * (m - 1)
k.sort()
for i in range(m - 1):
    d[i] = abs(k[i] - k[i + 1])
d = sorted(d, reverse=True)
res = 0
for i in range(n - 1):
    if i == m - 1:
        break
    res += d[i]
print((sum(d) - res))

n, m = list(map(int, input().split()))
k = list(map(int, input().split()))
d = [0] * (m - 1)
k.sort()
for i in range(m - 1):
    d[i] = abs(k[i] - k[i + 1])
d = sorted(d, reverse=True)
print((sum(d) - sum(d[: n - 1])))

-res = 0 -for i in range(n - 1): -    if i == m - 1: -        break -    res += d[i] -print((sum(d) - res)) +print((sum(d) - sum(d[: n - 1])))