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

if M == 1:

  print((0))

  exit()



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

difX = [0] + [X[i+1]-X[i] for i in range(M-1)]

difX.sort(reverse=True)

print((sum(difX)-sum(difX[:N-1])))
N, M = list(map(int, input().split()))

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

difX = [0]

for i in range(1, M):

    difX.append(X[i]-X[i-1])

difX.sort(reverse=True)

print((max(X) - min(X) - sum(difX[:N-1])))
N, M = list(map(int, input().split()))
if M == 1:
    print((0))
    exit()
X = sorted(list(map(int, input().split())))
difX = [0] + [X[i + 1] - X[i] for i in range(M - 1)]
difX.sort(reverse=True)
print((sum(difX) - sum(difX[: N - 1])))

N, M = list(map(int, input().split()))
X = sorted(list(map(int, input().split())))
difX = [0]
for i in range(1, M):
    difX.append(X[i] - X[i - 1])
difX.sort(reverse=True)
print((max(X) - min(X) - sum(difX[: N - 1])))

-if M == 1: -    print((0)) -    exit() -difX = [0] + [X[i + 1] - X[i] for i in range(M - 1)] +difX = [0] +for i in range(1, M): +    difX.append(X[i] - X[i - 1]) -print((sum(difX) - sum(difX[: N - 1]))) +print((max(X) - min(X) - sum(difX[: N - 1])))