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