I=lambda:list(map(int,input().split()));n,m=I();x=sorted(I());print((sum(sorted(j-i for i,j in zip(x,x[1:]))[:max(0,m-n)])))
n,m,*x=list(map(int,open(0).read().split()));x.sort();print((sum(sorted(j-i for i,j in zip(x,x[1:]))[::-1][n-1:])))
I = lambda: list(map(int, input().split()))
n, m = I()
x = sorted(I())
print((sum(sorted(j - i for i, j in zip(x, x[1:]))[: max(0, m - n)])))

n, m, *x = list(map(int, open(0).read().split()))
x.sort()
print((sum(sorted(j - i for i, j in zip(x, x[1:]))[::-1][n - 1 :])))

-I = lambda: list(map(int, input().split())) -n, m = I() -x = sorted(I()) -print((sum(sorted(j - i for i, j in zip(x, x[1:]))[: max(0, m - n)]))) +n, m, *x = list(map(int, open(0).read().split())) +x.sort() +print((sum(sorted(j - i for i, j in zip(x, x[1:]))[::-1][n - 1 :])))