#!/bin/ruby n = gets.strip.to_i calories = gets.strip calories = calories.split(' ').map(&:to_i) sum=0 calories.sort! k=0 i= n-1 while(i>=0) sum=sum+(calories[i]*(2**k)) k+=1 i=i-1 end print sum