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

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



if n >= m:

  print((0))

  exit()



l.sort()

d = [0]*(m-1)

for i in range(m-1):

  d[i] = l[i+1] - l[i]



d.sort()



print((sum(d[0:(m-n)])))





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

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



if n >= m:

    print((0))

    exit()



X.sort()



if n == 1:

    print((X[-1]-X[0]))

    exit()



Y = []

for i in range(m-1):

    Y.append(X[i+1]-X[i])

#print(Y)

Y.sort()

ans = sum(Y[0:-(n-1)])

print(ans)

n, m = list(map(int, input().split()))
l = list(map(int, input().split()))
if n >= m:
    print((0))
    exit()
l.sort()
d = [0] * (m - 1)
for i in range(m - 1):
    d[i] = l[i + 1] - l[i]
d.sort()
print((sum(d[0 : (m - n)])))

n, m = list(map(int, input().split()))
X = list(map(int, input().split()))
if n >= m:
    print((0))
    exit()
X.sort()
if n == 1:
    print((X[-1] - X[0]))
    exit()
Y = []
for i in range(m - 1):
    Y.append(X[i + 1] - X[i])
# print(Y)
Y.sort()
ans = sum(Y[0 : -(n - 1)])
print(ans)

-l = list(map(int, input().split())) +X = list(map(int, input().split())) -l.sort() -d = [0] * (m - 1) +X.sort() +if n == 1: +    print((X[-1] - X[0])) +    exit() +Y = [] -    d[i] = l[i + 1] - l[i] -d.sort() -print((sum(d[0 : (m - n)]))) +    Y.append(X[i + 1] - X[i]) +# print(Y) +Y.sort() +ans = sum(Y[0 : -(n - 1)]) +print(ans)