G. World Mug (B)
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

The organizers of the tournament wish to ensure a great amount of fun for the fans, for that, they have decided to rearrange the teams such that more goals in the tournament are scored.

Can you help out by calculating the maximum number of goals that could be scored if the teams were rearranged optimally?

Input

The first line of input contains one integer n (2 ≤ n ≤ 218), the number of teams participating in the tournament. It is guaranteed that the number of teams is a power of two (i.e., 2, 4, 8, 16, ...).

The second line contains n distinct integers, the ith integer is si (1 ≤ si ≤ 109), the strength of the ith team.

Output

On a single line, print the maximum number of goals that could be scored in the tournament if the teams were rearranged to maximize that number.

Example
Input
8
100 200 300 400 800 700 600 500
Output
2100