#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]; } sort(calories.begin(), calories.end()); reverse(calories.begin(), calories.end()); long result = 0; long term = 1; for(int i = 0; i < calories.size(); i++) { result = result + (term * calories[i]); term = term * 2; } cout << result << endl; // your code goes here return 0; }