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

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

X.sort()

if M > N:

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

    dist.sort(reverse = True)

    for i in range(N - 1):

        del dist[0]

    print((sum(dist)))

else:

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

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

X.sort()

if M > N:

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

    dist.sort(reverse = True)

    del dist[0:N-1]

    print((sum(dist)))

else:

 print((0))
N, M = list(map(int, (input().split())))
X = list(map(int, (input().split())))
X.sort()
if M > N:
    dist = [X[i + 1] - X[i] for i in range(M - 1)]
    dist.sort(reverse=True)
    for i in range(N - 1):
        del dist[0]
    print((sum(dist)))
else:
    print((0))

N, M = list(map(int, (input().split())))
X = list(map(int, (input().split())))
X.sort()
if M > N:
    dist = [X[i + 1] - X[i] for i in range(M - 1)]
    dist.sort(reverse=True)
    del dist[0 : N - 1]
    print((sum(dist)))
else:
    print((0))

-    for i in range(N - 1): -        del dist[0] +    del dist[0 : N - 1]