A-series#13033

A-series

1 second
256 megabytes
Medium

There are N+1 different sizes of paper: , , , , , where each size is twice larger than the next one.

You have a_0 pieces of paper of size , a_1 of size , , a_{N} pieces of size . You want to obtain at least b_0 pieces of size , b_1 of size , , b_{N} pieces of size . At any point you can fold and cut a paper in half, obtaining two pieces of smaller size (e.g. A4 \rightarrow A5 \times 2). What is the minimum number of cuts needed to obtain the required pieces?

Input

The first line contains a single integer (1 \le N \le 2\cdot 10^5).

The second line contains N+1 integers a_0, a_1, \ldots, a_N (0 \le a_i \le 10^9).

The third line contains N+1 integers b_0, b_1, \ldots, b_N (0 \le b_i \le 10^9).

Output

Output a single integer — the minimum number of cuts needed to obtain the required pieces, or , if it's not possible to obtain them.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading

Example 3

Loading
Loading