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

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



if N >= M:

    print((0))

else:

    X.sort()

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

    dX.sort(key=lambda x: x[1], reverse=True)

    print((sum(d[1] for d in dX[N - 1:])))
N, M = list(map(int, input().split()))

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



if N >= M:

    print((0))

else:

    X.sort()

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

    dX.sort(reverse=True)

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

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

-    dX = [(i, X[i + 1] - X[i]) for i in range(M - 1)] -    dX.sort(key=lambda x: x[1], reverse=True) -    print((sum(d[1] for d in dX[N - 1 :]))) +    dX = [X[i + 1] - X[i] for i in range(M - 1)] +    dX.sort(reverse=True) +    print((sum(dX[N - 1 :])))