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

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



if m <= n:

    print((0))

else:

    x.sort()

    diff = []#i番目とi+1番目の距離

    for i in range(m-1):

        diff.append(x[i+1] - x[i])

    diff.sort(reverse=True)

    # print(diff)

    if n > 1:

        for i in range(n-1):

            diff.pop(0)

    # print(diff)

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

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



x.sort()

d = []

for i in range(m-1):

    d.append(x[i+1] - x[i])



d.sort(reverse=True)

# print(d)



print((sum(d[n-1:])))
n, m = list(map(int, input().split()))
x = list(map(int, input().split()))
if m <= n:
    print((0))
else:
    x.sort()
    diff = []  # i番目とi+1番目の距離
    for i in range(m - 1):
        diff.append(x[i + 1] - x[i])
    diff.sort(reverse=True)
    # print(diff)
    if n > 1:
        for i in range(n - 1):
            diff.pop(0)
    # print(diff)
    print((sum(diff)))

n, m = list(map(int, input().split()))
x = list(map(int, input().split()))
x.sort()
d = []
for i in range(m - 1):
    d.append(x[i + 1] - x[i])
d.sort(reverse=True)
# print(d)
print((sum(d[n - 1 :])))

-if m <= n: -    print((0)) -else: -    x.sort() -    diff = []  # i番目とi+1番目の距離 -    for i in range(m - 1): -        diff.append(x[i + 1] - x[i]) -    diff.sort(reverse=True) -    # print(diff) -    if n > 1: -        for i in range(n - 1): -            diff.pop(0) -    # print(diff) -    print((sum(diff))) +x.sort() +d = [] +for i in range(m - 1): +    d.append(x[i + 1] - x[i]) +d.sort(reverse=True) +# print(d) +print((sum(d[n - 1 :])))