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

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

if M <= N:

    print((0))

else:

    Y = []

    for i in range(1, len(X)):

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

    Y = sorted(Y)

    if N == 1:

        print((sum(Y)))

    else:

        print((sum(Y[:-(N-1)])))

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

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

X.sort()

t = [0] * (M - 1)

for i in range(1, M):

    t[i - 1] = X[i] - X[i - 1]

t.sort(reverse=True)

print((sum(t[N - 1:])))

N, M = list(map(int, input().split()))
X = sorted(list(map(int, input().split())))
if M <= N:
    print((0))
else:
    Y = []
    for i in range(1, len(X)):
        Y.append(X[i] - X[i - 1])
    Y = sorted(Y)
    if N == 1:
        print((sum(Y)))
    else:
        print((sum(Y[: -(N - 1)])))

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

-X = sorted(list(map(int, input().split()))) -if M <= N: -    print((0)) -else: -    Y = [] -    for i in range(1, len(X)): -        Y.append(X[i] - X[i - 1]) -    Y = sorted(Y) -    if N == 1: -        print((sum(Y))) -    else: -        print((sum(Y[: -(N - 1)]))) +X = list(map(int, input().split())) +X.sort() +t = [0] * (M - 1) +for i in range(1, M): +    t[i - 1] = X[i] - X[i - 1] +t.sort(reverse=True) +print((sum(t[N - 1 :])))