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