import Foundation
var n = Int(readLine()!)!
var A : [Int] = Int
var B : [Int] = Int
A = (readLine()!.split(separator: " ").map{Int(String($0))!})
B = (readLine()!.split(separator: " ").map{Int(String($0))!})
A = A.sorted{$0>$1}
B = B.sorted{$1>$0}
var result = zip(A, B).reduce(0){ a,b in
// print(a)
return a + b.0 * b.1 }
print(result)