#Uses python3

import sys

def max_dot_product(a, b):
    n = len(a)
    res = 0
    for i in range(n):
        max_a = max(a)
        max_b = max(b)
        del a[a.index(max_a)]
        del b[b.index(max_b)]
        res += max_a * max_b
    return res

if __name__ == '__main__':
    input = sys.stdin.read()
    # input = input()
    data = list(map(int, input.split()))
    n = data[0]
    a = data[1:(n + 1)]
    b = data[(n + 1):]
    print(max_dot_product(a, b))
    
# 1 23 39
# 3 1 3 -5 -2 4 1