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

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

d = [0] * (M - 1)

ans = 0



if N >= M:

    print(ans)

else:

    for i in range(M - 1):

        d[i] = abs(X[i + 1] - X[i])

    d.sort(reverse=True)

    b = d[:N - 1]

    for i in range(M - 1):

        if d[i] in b:

            b.remove(d[i])

        else:

            ans += d[i]

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

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

d = [0] * (M - 1)



if N >= M:

    print((0))

else:

    for i in range(M - 1):

        d[i] = abs(X[i + 1] - X[i])

    d.sort(reverse=True)

    print((sum(d[N - 1:])))
N, M = list(map(int, input().split()))
X = sorted(list(map(int, input().split())))
d = [0] * (M - 1)
ans = 0
if N >= M:
    print(ans)
else:
    for i in range(M - 1):
        d[i] = abs(X[i + 1] - X[i])
    d.sort(reverse=True)
    b = d[: N - 1]
    for i in range(M - 1):
        if d[i] in b:
            b.remove(d[i])
        else:
            ans += d[i]
    print(ans)

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

-ans = 0 -    print(ans) +    print((0)) -    b = d[: N - 1] -    for i in range(M - 1): -        if d[i] in b: -            b.remove(d[i]) -        else: -            ans += d[i] -    print(ans) +    print((sum(d[N - 1 :])))