문제 링크 - https://www.acmicpc.net/problem/1026
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
answer = 0
while True:
high = max(b)
low = min(a)
answer += high * low
del a[a.index(min(a))]
del b[b.index(max(b))]
if not a:
break
print(answer)