#!/bin/python3 import sys n = int(input().strip()) calories = list(map(int, input().strip().split(' '))) calories = sorted(calories, reverse=True) z = 0 for x in range(n): z += calories[x]*(2**x) print(z) # your code goes here