n, m = list(map(int, input().split()))

x = sorted(map(int, input().split()))

if n >= m:

    print((0))

else:

    dif = []

    for i in range(m-1):

        dif.append(x[i + 1] - x[i])

    dif = sorted(dif)

    for _ in range(n-1):

        dif.pop()

    print((sum(dif)))
n, m = list(map(int, input().split()))

x = sorted(map(int, input().split()))

if n >= m:

    print((0))

else:

    dif = []

    for i in range(m-1):

        dif.append(x[i + 1] - x[i])

    print((sum(dif) if n == 1 else sum(sorted(dif)[:-(n-1)])))

n, m = list(map(int, input().split()))
x = sorted(map(int, input().split()))
if n >= m:
    print((0))
else:
    dif = []
    for i in range(m - 1):
        dif.append(x[i + 1] - x[i])
    dif = sorted(dif)
    for _ in range(n - 1):
        dif.pop()
    print((sum(dif)))

n, m = list(map(int, input().split()))
x = sorted(map(int, input().split()))
if n >= m:
    print((0))
else:
    dif = []
    for i in range(m - 1):
        dif.append(x[i + 1] - x[i])
    print((sum(dif) if n == 1 else sum(sorted(dif)[: -(n - 1)])))

-    dif = sorted(dif) -    for _ in range(n - 1): -        dif.pop() -    print((sum(dif))) +    print((sum(dif) if n == 1 else sum(sorted(dif)[: -(n - 1)])))