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

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



XList = sorted(XList)

deltaList = [0]



for i in range(M-1) :

    deltaList.append(XList[i+1] - XList[i])

deltaList = sorted(deltaList, reverse=True)





for i in range(N-1) :

    deltaList[i] = 0

    if i == len(deltaList)-1 :

        break

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

xList = [int(i) for i in input().split(" ")]

xList = sorted(xList)

dList = [0]

for i in range(len(xList) -1) :

    dList.append(xList[i+1] - xList[i])

dList = sorted(dList, reverse=True)    



for i in range(n-1) :

    dList[i] = 0

    if(i == len(dList) -1) :

        break

print((sum(dList)))
N, M = list(map(int, input().split(" ")))
XList = list(map(int, input().split()))
XList = sorted(XList)
deltaList = [0]
for i in range(M - 1):
    deltaList.append(XList[i + 1] - XList[i])
deltaList = sorted(deltaList, reverse=True)
for i in range(N - 1):
    deltaList[i] = 0
    if i == len(deltaList) - 1:
        break
print((sum(deltaList)))

n, m = list(map(int, input().split(" ")))
xList = [int(i) for i in input().split(" ")]
xList = sorted(xList)
dList = [0]
for i in range(len(xList) - 1):
    dList.append(xList[i + 1] - xList[i])
dList = sorted(dList, reverse=True)
for i in range(n - 1):
    dList[i] = 0
    if i == len(dList) - 1:
        break
print((sum(dList)))

-N, M = list(map(int, input().split(" "))) -XList = list(map(int, input().split())) -XList = sorted(XList) -deltaList = [0] -for i in range(M - 1): -    deltaList.append(XList[i + 1] - XList[i]) -deltaList = sorted(deltaList, reverse=True) -for i in range(N - 1): -    deltaList[i] = 0 -    if i == len(deltaList) - 1: +n, m = list(map(int, input().split(" "))) +xList = [int(i) for i in input().split(" ")] +xList = sorted(xList) +dList = [0] +for i in range(len(xList) - 1): +    dList.append(xList[i + 1] - xList[i]) +dList = sorted(dList, reverse=True) +for i in range(n - 1): +    dList[i] = 0 +    if i == len(dList) - 1: -print((sum(deltaList))) +print((sum(dList)))