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