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