Ilya is a very good-natured lion. He likes maths. Of all mathematical objects, his favourite one is matrices. Now he's faced a complicated matrix problem he needs to solve.

He's got a square 2^{n} × 2^{n}-sized matrix and 4^{n} integers. You need to arrange all these numbers in the matrix (put each number in a single individual cell) so that the beauty of the resulting matrix with numbers is maximum.

The beauty of a 2^{n} × 2^{n}-sized matrix is an integer, obtained by the following algorithm:  Find the maximum element in the matrix. Let's denote it as m.  If n = 0, then the beauty of the matrix equals m. Otherwise, a matrix can be split into 4 non-intersecting 2^{n} - 1 × 2^{n} - 1-sized submatrices, then the beauty of the matrix equals the sum of number m and other four beauties of the described submatrices. 

As you can see, the algorithm is recursive.

Help Ilya, solve the problem and print the resulting maximum beauty of the matrix.


-----Input-----

The first line contains integer 4^{n} (1 ≤ 4^{n} ≤ 2·10^6). The next line contains 4^{n} integers a_{i} (1 ≤ a_{i} ≤ 10^9) — the numbers you need to arrange in the 2^{n} × 2^{n}-sized matrix.


-----Output-----

On a single line print the maximum value of the beauty of the described matrix.

Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.


-----Examples-----
Input
1
13

Output
13

Input
4
1 2 3 4

Output
14



-----Note-----

Consider the second sample. You need to arrange the numbers in the matrix as follows:

1 2

3 4



Then the beauty of the matrix will equal: 4 + 1 + 2 + 3 + 4 = 14.

Difficulty: interview

Starter code:

Solutions:
n = int(input())
arr = list(map(float, input().split()))
if n == 1:
    print(int(arr[0]))
    return
arr.sort(reverse = True)
res = 0
while arr:
    res += sum(arr)
    arr = arr[:len(arr)//4]
print(int(res))


from sys import stdin
n = int(stdin.readline())
arr = list(map(float, stdin.readline().split()))
if n == 1:
    print(int(arr[0]))
    return
arr.sort(reverse = True)
res = 0
while arr:
    res += sum(arr)
    arr = arr[:len(arr)//4]
print(int(res))

n = int(input())
arr = list(map(float, input().split()))
arr.sort(reverse = True)
res = 0
while arr:
    res += sum(arr)
    arr = arr[:len(arr)//4]
print(int(res))



def __starting_point():
    n = int(input())
    a = list(map(float, input().split()))
    a.sort(reverse=True)
    res = 0
    # a is sorted in desc
    while(a):
        res += sum(a)
        a = a[:len(a)//4]

    print(int(res))
__starting_point()

def arr_inp():
    return [float(x) for x in input().split()]

def solve(n):
    nonlocal s
    if n == 1:
        s += a[0]
        return
    else:
        solve(n // 4)
    s += sum(a[:n])


n, a, s = int(input()), arr_inp(), 0
a = sorted(a, reverse=True)
while (a):
    s += sum(a)
    n //= 4
    a = a[:n]

print(int(s))


def arr_inp():
    return [float(x) for x in input().split()]


def solve(n):
    nonlocal s
    if n == 1:
        s += a[0]
        return
    else:
        solve(n // 4)
    s += sum(a[:n])


n, a, s = int(input()), arr_inp(), 0
a = sorted(a, reverse=True)
solve(n)
print(int(s))


def arr_inp():
    return [float(x) for x in input().split()]


def solve(n):
    nonlocal s
    if n == 1:
        s += a[0]
        return
    else:
        solve(n // 4)
    s += sum(a[:n])


n, a, s = int(input()), sorted(arr_inp(), reverse=True), 0
solve(n)
print(int(s))


n=int(input())
a=list(map(float, input().split()))
a.sort(reverse=True)
su=0
while(a):
    su += sum(a)
    a=a[:len(a)//4]
print(int(su))

n = int(input())
a = list(map(float, input().split()))
a.sort(reverse=True)
res = 0
while(a):
    res += sum(a)
    a = a[:len(a)//4]
print(int(res))

n=int(input())
a=list(map(float, input().split()))
a.sort(reverse=True)
su=0
while(a):
    su += sum(a)
    a=a[:len(a)//4]
print(int(su))

n=int(input())
a=list(map(float,input().split()))
a.sort(reverse=True)
ans=0
while(a):
    ans += sum(a)
    a=a[:len(a)//4]
print(int(ans))

n = int(input())
a = list(map(float, input().split()))
a.sort(reverse = True)
res = 0
l=len(a)
while a:
    res += sum(a)
    l=l//4
    a = a[:l]
print(int(res))