There is an infinitely long one-dimensional coordinate line whose points are the negative integers, 0, and the positive integers. Minho stands on one point of this line.
In front of Minho there is a shop that sells n cards. Card i is labeled with a length li and a price ci. If Minho pays ci won for that card, he can jump from any point x to x−li or to x+li.
At the start Minho owns no card, so he cannot leave the point he stands on. Once he spends money on cards, he can jump to other points.
Minho wants to buy some cards so that every point of the line becomes reachable. If such a purchase exists, he wants to spend as little money as possible.
Write a program that decides whether some set of cards makes every point reachable and, when it does, computes the smallest possible cost.
Input
The first line contains the number of cards n (1≤n≤300).
The second line contains the lengths of the n cards, l1,l2,…,ln (1≤li≤109).
The third line contains the prices of the n cards, c1,c2,…,cn (1≤ci≤105).
Output
If no set of cards makes every point reachable, print −1.
Otherwise, print the smallest cost among the purchases that make every point reachable.