#!/bin/python3 import sys n = int(input().strip()) calories = list(reversed(sorted(list(map(int, input().strip().split(' ')))))) total = 0 for i, c in enumerate(calories): total += pow(2, i)*c print(total) # your code goes here