N,M=list(map(int,input().split()))

X=[int(i) for i in input().split()]

X.sort()

count=[]

sum=0

if N<M:

  for i in range(M):

    if i != 0:

      count.append(X[i]-get)

      sum+=count[i-1]

    get=X[i]

  count.sort(reverse=True)

  

  for i in range(N-1):

    sum-=count[i]

print(sum)

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

x = [int(i) for i in input().split()]

x.sort()

xx = []

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

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

xx.sort()

print((sum(xx[:-(n-1)])if n!=1 else sum(xx)))

N, M = list(map(int, input().split()))
X = [int(i) for i in input().split()]
X.sort()
count = []
sum = 0
if N < M:
    for i in range(M):
        if i != 0:
            count.append(X[i] - get)
            sum += count[i - 1]
        get = X[i]
    count.sort(reverse=True)
    for i in range(N - 1):
        sum -= count[i]
print(sum)

n, m = list(map(int, input().split()))
x = [int(i) for i in input().split()]
x.sort()
xx = []
for i in range(len(x) - 1):
    xx.append(abs(x[i] - x[i + 1]))
xx.sort()
print((sum(xx[: -(n - 1)]) if n != 1 else sum(xx)))

-N, M = list(map(int, input().split())) -X = [int(i) for i in input().split()] -X.sort() -count = [] -sum = 0 -if N < M: -    for i in range(M): -        if i != 0: -            count.append(X[i] - get) -            sum += count[i - 1] -        get = X[i] -    count.sort(reverse=True) -    for i in range(N - 1): -        sum -= count[i] -print(sum) +n, m = list(map(int, input().split())) +x = [int(i) for i in input().split()] +x.sort() +xx = [] +for i in range(len(x) - 1): +    xx.append(abs(x[i] - x[i + 1])) +xx.sort() +print((sum(xx[: -(n - 1)]) if n != 1 else sum(xx)))