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