n = gets.to_i a = gets.split(" ").map(&:to_i).sort.reverse ans = 0 for i in 0...n do ans += 2**i * (a[i]) end puts ans