Competitions

# Sequences + Longest Common Subsequence

# Minimal Sum

Two arrays of positive integers are given: `a`

and _{1..n}`b`

. Find the permutation _{1..n}`i`

, _{1}`i`

, ..., _{2}`i`

of numbers _{n}**1**, **2**, ..., **n**, for which the sum

`a`

* _{1}`b`

+ ... + _{i1}`a`

* _{n}`b`

_{in}

is minimal. Each number must be included in permutation only once.

#### Input

The first line contains the number of elements **n** (**n** ≤ **100**) in 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}

#### Output

Print the minimal value of required sum.

Input example

5 7 2 4 3 10 5 11 6 9 6

Output example

165