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?
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 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.
5 1 2 3 4 5 5 4 3 2 1
20
3 10 1 10 1 5 1
18
5 0 0 0 0 0 10 10 10 10 10
-1
10 79 94 92 29 10 81 76 31 64 33 12 46 2 14 89 90 34 51 64 13
472