#!/bin/python3 import sys n = int(input().strip()) c = list(map(int, input().strip().split(' '))) sum=0 # your code goes here for i in range(len(c)): sum=sum+int(max(c)*(2**i)); c.remove(max(c)) print(sum)