Problems
Minimum Sum
Minimum Sum
There are two arrays of positive integers $a[1..n]$ and $b[1..n]$. Find a permutation $i_1, i_2, ..., i_n$ of numbers $1, 2, ..., n$, for which the sum
$$
a_1 \cdot b_{i_1} + ... + a_n \cdot b_{i_n}
$$
is minimal. Each number should appear only once in the permutation.
\InputFile
The first line contains the number of elements $n~(n \le 100)$ in the arrays. The second line contains the elements of the first array, and the third line contains the elements of the second array. The array elements do not exceed $10^6$.
\OutputFile
Print the minimal value of required sum.
Input example #1
5 7 2 4 3 10 5 11 6 9 6
Output example #1
165