Monocarp is playing a game. The game is divided into stages, and there are a total of $$$1337$$$ stages. The game character uses a weapon with two attack modes: physical and elemental. Initially, the weapon's physical attack power is $$$1$$$, and its elemental attack power is also $$$1$$$.
During the $$$i$$$-th stage of the game, the following events occur in order:
After each kill, Monocarp can upgrade one of the attacks of the weapon by $$$1$$$.
Your task is to calculate the minimum damage that Monocarp can get in order to kill all the monsters in the game (or report that it is impossible to kill all the monsters).
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 500$$$).
The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 500$$$).
The third line contains $$$n$$$ integers $$$b_1, b_2, \dots, b_n$$$ ($$$1 \le b_i \le 500$$$).
Print a single integer — the minimum damage that Monocarp can get in order to kill all the monsters in the game; if it is impossible to kill all the monsters, print -1.
42 1 5 35 1 3 2
4
43 1 5 35 1 3 2
-1
31 1 11 2 3
0
86 4 1 2 3 5 1 66 3 2 1 2 3 4 3
16
In the first example, Monocarp can proceed as follows:
$$$1$$$-st stage: