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