Cooking Steaks

시간 제한1초메모리 제한2048 MB

문제

Morgan is a chef in a steak house. In his steak house, a steak can have $N$ level of doneness, numbered from $1$ to $N$. Currently, Morgan has $A_i$ steaks of doneness level $i$ ready in his steak house.

There are $B_i$ orders of steaks with doneness level $i$ that need to be fulfilled. Morgan can cook the steaks in order to match the doneness level. For each $1 ≤ i < N$, it takes Morgan $T_i$ seconds to cook a steak from doneness level $i$ to $i + 1$. Note that Morgan can only cook one steak at a time.

Morgan asks for your help to find the minimum total time to fulfil all orders, or tell him that the orders are impossible to fulfil.

입력

Input begins with an integer $N$ ($2 ≤ N ≤ 100\, 000$). The next line contains $N - 1$ integers $T_i$ ($1 ≤ T_i ≤ 1000$) representing the time required to cook a steak of doneness level $i$ to $i+ 1$. The next line contains $N$ integers $A_i$ ($0 ≤ A_i ≤ 1000$) representing the number of steaks with doneness level $i$. The next line contains $N$ integers $B_i$ ($0 ≤ B_i ≤ 1000$) representing the number of orders for a steak with doneness level $i$.

출력

If all orders can be fulfilled, then output an integer in a single line representing the minimum total time to fulfill all orders. Otherwise, output -1 in a single line.