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

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

x.sort()

dis = []

if n >= m:

    print((0))

else:    

    for i in range(m-1):

        dis.append(abs(x[i+1]-x[i]))

    dis.sort(reverse=True)

    for i in range(n-1):

        dis.pop(0)

    ans = sum(dis)

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

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

dif = []

x.sort()



for i in range(len(x)-1):

    dif.append(abs(x[i]-x[i+1]))

    

dif.sort(reverse=True)



ans = sum(dif[n-1:])

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

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

+dif = [] -dis = [] -if n >= m: -    print((0)) -else: -    for i in range(m - 1): -        dis.append(abs(x[i + 1] - x[i])) -    dis.sort(reverse=True) -    for i in range(n - 1): -        dis.pop(0) -    ans = sum(dis) -    print(ans) +for i in range(len(x) - 1): +    dif.append(abs(x[i] - x[i + 1])) +dif.sort(reverse=True) +ans = sum(dif[n - 1 :]) +print(ans)