There are N mountains, numbered 1 to N from left to right. Doremon is standing on mountain no 1 and wants to reach mountain no N. He has a special device called Jetpack, which enables him to fly from one mountain to another. He can fly from mountain number i to mountain number j if and only if i < j and j-i is a power of 2 (1,2,4, so on). Such a move costs him fuel |Height[j]-Height[i]|, where Height[i] is the height of the ith mountain. Find the minimum amount of fuel using which Doremon can reach Mountain N.
INPUT
First line contains N, number of mountains. Next line contains N space-separated integers, denoting the array Height.
OUTPUT
Print a single integer, the answer to the above problem.
CONSTRAINTS
1 <= N <= 200000
1 <= Height[i] <= 109
Doremon will fly directly from mountain 1 to mountain 5 because 5 - 1 = 4(which is 2 to the power 2). So fuel spent = |Height[5]-Height[1]| = 5-1 =4, 4 is the minimum amount of fuel spent.