J. Stacking Trick
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Rory the Reptile Rescuer is trying to teach their iguana some new tricks!

For this trick, Rory sets up $$$n$$$ stacks of blocks on a table, where the $$$i$$$th stack contains $$$a_i$$$ blocks. The iguana will then perform a series of block moves, where it moves a block from one stack to an adjacent one. The iguana can also push a block from stack $$$1$$$ or $$$n$$$ off the table. After the iguana performs all of its moves, the $$$i$$$th stack should now contain $$$b_i$$$ blocks.

Rory is worried that training the iguana to do this will take a lot of time, and wants to minimize the number of moves the iguana must perform to transform the block display. Can you help Rory?

Input

The first line contains $$$n$$$ ($$$1 \leq n \leq 10^5$$$), the number of stacks. The second line contains $$$n$$$ integers, $$$a_1, \ldots, a_n$$$ ($$$0 \leq a_i \leq 10^{12}$$$), the number of blocks in each stack initially. The last line contains $$$n$$$ integers, $$$b_1, \ldots, b_n$$$ ($$$0 \leq b_i \leq 10^{12}$$$), the number of blocks that each stack should have at the end of the trick.

Output

Output a single integer, the minimum number of adjacent block moves (including pushing a block off the table) the iguana needs to achieve the desired block display, or $$$-1$$$ if it is not possible.

Examples
Input
5
1 2 3 4 5
5 4 3 2 1
Output
20
Input
3
10 1 10
1 5 1
Output
18
Input
5
0 0 0 0 0
10 10 10 10 10
Output
-1
Input
10
79 94 92 29 10 81 76 31 64 33
12 46 2 14 89 90 34 51 64 13
Output
472