#include #define Nmax 47 #define FOR(i, l, r) for(int i=l; i<=r; ++i) using namespace std; typedef unsigned long long ull; bool cmp(int a, int b) { return a > b; } ull pow(int n, int m) { if (m == 1) return n; else if (m == 0) return 1; ull tmp = pow(n, m/2); if (m%2 == 1) return tmp*tmp*n; else return tmp*tmp; } int main() { ull n, c[Nmax], res = 0; cin >> n; FOR(i, 0, n-1) cin >> c[i]; sort(c, c+n, cmp); FOR(i, 0, n-1) { res += c[i]*pow(2, i); } cout << res; return 0; }