import sys

input = sys.stdin.readline

from bisect import bisect_left, bisect_right





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

P = [int(eval(input())) for _ in range(W)]

P.sort()



Q = [int(eval(input())) for _ in range(H)]

Q.sort()



ans = 0

for q in Q:

    tmp = bisect_right(P, q)

    # print ('tmp=', tmp)

    ans += q * (1 + W - tmp)

    # print (ans)



for p in P:

    tmp = bisect_left(Q, p)

    ans += p * (1 + H - tmp)



print (ans)

# print ('P:', P)

# print ('Q:', Q)
def main():

    import sys

    input = sys.stdin.readline

    from bisect import bisect_left, bisect_right





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

    P = [int(eval(input())) for _ in range(W)]

    P.sort()



    Q = [int(eval(input())) for _ in range(H)]

    Q.sort()



    ans = 0

    for q in Q:

        tmp = bisect_right(P, q)

        # print ('tmp=', tmp)

        ans += q * (1 + W - tmp)

        # print (ans)



    for p in P:

        tmp = bisect_left(Q, p)

        ans += p * (1 + H - tmp)



    print (ans)

    # print ('P:', P)

    # print ('Q:', Q)



if __name__ == '__main__':

    main()
import sys

input = sys.stdin.readline
from bisect import bisect_left, bisect_right

W, H = list(map(int, input().split()))
P = [int(eval(input())) for _ in range(W)]
P.sort()
Q = [int(eval(input())) for _ in range(H)]
Q.sort()
ans = 0
for q in Q:
    tmp = bisect_right(P, q)
    # print ('tmp=', tmp)
    ans += q * (1 + W - tmp)
    # print (ans)
for p in P:
    tmp = bisect_left(Q, p)
    ans += p * (1 + H - tmp)
print(ans)
# print ('P:', P)
# print ('Q:', Q)

def main():
    import sys

    input = sys.stdin.readline
    from bisect import bisect_left, bisect_right

    W, H = list(map(int, input().split()))
    P = [int(eval(input())) for _ in range(W)]
    P.sort()
    Q = [int(eval(input())) for _ in range(H)]
    Q.sort()
    ans = 0
    for q in Q:
        tmp = bisect_right(P, q)
        # print ('tmp=', tmp)
        ans += q * (1 + W - tmp)
        # print (ans)
    for p in P:
        tmp = bisect_left(Q, p)
        ans += p * (1 + H - tmp)
    print(ans)
    # print ('P:', P)
    # print ('Q:', Q)


if __name__ == "__main__":
    main()

-import sys +def main(): +    import sys -input = sys.stdin.readline -from bisect import bisect_left, bisect_right +    input = sys.stdin.readline +    from bisect import bisect_left, bisect_right -W, H = list(map(int, input().split())) -P = [int(eval(input())) for _ in range(W)] -P.sort() -Q = [int(eval(input())) for _ in range(H)] -Q.sort() -ans = 0 -for q in Q: -    tmp = bisect_right(P, q) -    # print ('tmp=', tmp) -    ans += q * (1 + W - tmp) -    # print (ans) -for p in P: -    tmp = bisect_left(Q, p) -    ans += p * (1 + H - tmp) -print(ans) -# print ('P:', P) -# print ('Q:', Q) +    W, H = list(map(int, input().split())) +    P = [int(eval(input())) for _ in range(W)] +    P.sort() +    Q = [int(eval(input())) for _ in range(H)] +    Q.sort() +    ans = 0 +    for q in Q: +        tmp = bisect_right(P, q) +        # print ('tmp=', tmp) +        ans += q * (1 + W - tmp) +        # print (ans) +    for p in P: +        tmp = bisect_left(Q, p) +        ans += p * (1 + H - tmp) +    print(ans) +    # print ('P:', P) +    # print ('Q:', Q) + + +if __name__ == "__main__": +    main()