package boj;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
public class boj_1026 {
public static void main(String[] args) throws IOException {
BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter w = new BufferedWriter(new OutputStreamWriter(System.out));
r.readLine();
List<Integer> read1 = Arrays.stream(r.readLine().split(" "))
.map(Integer::parseInt)
.sorted()
.collect(Collectors.toList());
List<Integer> read2 = Arrays.stream(r.readLine().split(" "))
.map(Integer::parseInt)
.sorted(Comparator.reverseOrder())
.collect(Collectors.toList());
int sum = IntStream.range(0, read1.size())
.map(i -> read1.get(i) * read2.get(i))
.sum();
w.write(String.valueOf(sum));
w.flush();
}
}