W, H = list(map(int, input().split()))

P = [(int(eval(input())), 0) for i in range(W)]

Q = [(int(eval(input())), 1) for i in range(H)]



E = sorted(P + Q)

used = [W + 1, H + 1]



ans = 0

for e, f in E:

    ans += e * used[1 - f]

    used[f] -= 1



print(ans)

from itertools import accumulate

from bisect import bisect_left

W, H = list(map(int, input().split()))

W_cost = sorted([int(eval(input())) for i in range(W)])

H_cost = [int(eval(input())) for i in range(H)]





# 横は全部辺を張り、縦は各区間1本

W_cost_sum = sum(W_cost)

ans = W_cost_sum * (H + 1) + sum(H_cost)





W_acc_cost = [0] + list(accumulate(W_cost))

for h in H_cost:

    hx = bisect_left(W_cost, h)

    ans -= (W_cost_sum - W_acc_cost[hx]) - ((W - hx) * h)



print(ans)

W, H = list(map(int, input().split()))
P = [(int(eval(input())), 0) for i in range(W)]
Q = [(int(eval(input())), 1) for i in range(H)]
E = sorted(P + Q)
used = [W + 1, H + 1]
ans = 0
for e, f in E:
    ans += e * used[1 - f]
    used[f] -= 1
print(ans)

from itertools import accumulate
from bisect import bisect_left

W, H = list(map(int, input().split()))
W_cost = sorted([int(eval(input())) for i in range(W)])
H_cost = [int(eval(input())) for i in range(H)]
# 横は全部辺を張り、縦は各区間1本
W_cost_sum = sum(W_cost)
ans = W_cost_sum * (H + 1) + sum(H_cost)
W_acc_cost = [0] + list(accumulate(W_cost))
for h in H_cost:
    hx = bisect_left(W_cost, h)
    ans -= (W_cost_sum - W_acc_cost[hx]) - ((W - hx) * h)
print(ans)

+from itertools import accumulate +from bisect import bisect_left + -P = [(int(eval(input())), 0) for i in range(W)] -Q = [(int(eval(input())), 1) for i in range(H)] -E = sorted(P + Q) -used = [W + 1, H + 1] -ans = 0 -for e, f in E: -    ans += e * used[1 - f] -    used[f] -= 1 +W_cost = sorted([int(eval(input())) for i in range(W)]) +H_cost = [int(eval(input())) for i in range(H)] +# 横は全部辺を張り、縦は各区間1本 +W_cost_sum = sum(W_cost) +ans = W_cost_sum * (H + 1) + sum(H_cost) +W_acc_cost = [0] + list(accumulate(W_cost)) +for h in H_cost: +    hx = bisect_left(W_cost, h) +    ans -= (W_cost_sum - W_acc_cost[hx]) - ((W - hx) * h)