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

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

x = sorted(x)

if m<=n:

    print((0))

else:

    dif = []

    for i in range(m-1):

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

    dif = sorted(dif)

    print((sum(dif[:m-n])))
n,m = list(map(int,input().split()))

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

dif = []

for i in range(m-1):

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

dif.sort()

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

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

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