#include using namespace std; int main(){ int n; cin >> n; vector calories(n); for(int calories_i = 0; calories_i < n; calories_i++){ cin >> calories[calories_i]; } // your code goes here std::sort(calories.begin(), calories.end(), std::greater()); long ans = 0; long cur_two_pow = 1; long eaten = 0; for(int i = 0; i < calories.size(); ++i){ ans += calories[i] * cur_two_pow; eaten++; cur_two_pow *= 2; } std::cout << ans << std::endl; return 0; }