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

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

x.sort()

diff = []

for i in range(1, len(x)):

    diff.append(x[i] - x[i-1])

diff.sort(reverse=True)

sum = 0

for i in range(n - 1, len(diff)):

    sum += diff[i]

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

if n >= m:

    print((0))

    exit(0)



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

gaps = sorted([x[i] - x[i-1] for i in range(1, m)], reverse=True)

print((sum(gaps[n-1:])))

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

n, m = list(map(int, input().split()))
if n >= m:
    print((0))
    exit(0)
x = sorted(list(map(int, input().split())))
gaps = sorted([x[i] - x[i - 1] for i in range(1, m)], reverse=True)
print((sum(gaps[n - 1 :])))

-(n, m) = list(map(int, input().split())) -x = list(map(int, input().split())) -x.sort() -diff = [] -for i in range(1, len(x)): -    diff.append(x[i] - x[i - 1]) -diff.sort(reverse=True) -sum = 0 -for i in range(n - 1, len(diff)): -    sum += diff[i] -print(sum) +n, m = list(map(int, input().split())) +if n >= m: +    print((0)) +    exit(0) +x = sorted(list(map(int, input().split()))) +gaps = sorted([x[i] - x[i - 1] for i in range(1, m)], reverse=True) +print((sum(gaps[n - 1 :])))