import numpy as np

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

X = sorted(np.array(input().split(), dtype = np.int64))

X = sorted(np.diff(X))

if m-n >= 0:

    ans = sum(X[:m-n])

else:

    ans = 0

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

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

x.sort()

ans = []

for i in range(m-1):

    ans.append(abs(x[i]-x[i+1]))

ans.sort(reverse=True)

print((sum(ans[n-1:])))
import numpy as np

n, m = list(map(int, input().split()))
X = sorted(np.array(input().split(), dtype=np.int64))
X = sorted(np.diff(X))
if m - n >= 0:
    ans = sum(X[: m - n])
else:
    ans = 0
print(ans)

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

-import numpy as np - -X = sorted(np.array(input().split(), dtype=np.int64)) -X = sorted(np.diff(X)) -if m - n >= 0: -    ans = sum(X[: m - n]) -else: -    ans = 0 -print(ans) +x = list(map(int, input().split())) +x.sort() +ans = [] +for i in range(m - 1): +    ans.append(abs(x[i] - x[i + 1])) +ans.sort(reverse=True) +print((sum(ans[n - 1 :])))