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