import numpy as np



N, M = list(map(int, input().split()))

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



X.sort()



D = np.diff(X)



D.sort()



print((0 if M <= N else np.sum(D[:M-N])))

N, M = list(map(int, input().split()))

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



X.sort()



D = [X[i+1] - X[i] for i in range(M - 1)]



D.sort()



print((0 if M <= N else sum(D[:M-N])))
import numpy as np

N, M = list(map(int, input().split()))
X = list(set(map(int, input().split())))
X.sort()
D = np.diff(X)
D.sort()
print((0 if M <= N else np.sum(D[: M - N])))

N, M = list(map(int, input().split()))
X = list(map(int, input().split()))
X.sort()
D = [X[i + 1] - X[i] for i in range(M - 1)]
D.sort()
print((0 if M <= N else sum(D[: M - N])))

-import numpy as np - -X = list(set(map(int, input().split()))) +X = list(map(int, input().split())) -D = np.diff(X) +D = [X[i + 1] - X[i] for i in range(M - 1)] -print((0 if M <= N else np.sum(D[: M - N]))) +print((0 if M <= N else sum(D[: M - N])))