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

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



if N>=M:

    print((0))

else:

    lst_diff = []

    for i in range(M-1):

        diff = abs(lst_X[i] - lst_X[i+1])

        lst_diff.append(diff)

    lst_diff.sort(reverse=True)

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



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

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



if N>=M:

    print((0))

else:

    lst_diff = sorted([lst_X[i+1]-lst_X[i] for i in range(M-1)])[:M-N]

    print((sum(lst_diff)))



N, M = list(map(int, input().split()))
lst_X = sorted(list(map(int, input().split())))
if N >= M:
    print((0))
else:
    lst_diff = []
    for i in range(M - 1):
        diff = abs(lst_X[i] - lst_X[i + 1])
        lst_diff.append(diff)
    lst_diff.sort(reverse=True)
    print((sum(lst_diff[N - 1 :])))

N, M = list(map(int, input().split()))
lst_X = sorted(list(map(int, input().split())))
if N >= M:
    print((0))
else:
    lst_diff = sorted([lst_X[i + 1] - lst_X[i] for i in range(M - 1)])[: M - N]
    print((sum(lst_diff)))

-    lst_diff = [] -    for i in range(M - 1): -        diff = abs(lst_X[i] - lst_X[i + 1]) -        lst_diff.append(diff) -    lst_diff.sort(reverse=True) -    print((sum(lst_diff[N - 1 :]))) +    lst_diff = sorted([lst_X[i + 1] - lst_X[i] for i in range(M - 1)])[: M - N] +    print((sum(lst_diff)))