#pragma GCC optimize("O3") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx") #define __USE_MINGW_ANSI_STDIO 0 #include using namespace std; #define PI acos(-1) #define pb push_back #define fi first #define se second #define sz(a) (int)(a).size() #define all(c) (c).begin(), (c).end() #define TIMESTAMP fprintf(stderr, "Execution time: %.3lf s.\n", (double)clock()/CLOCKS_PER_SEC) typedef long long ll; typedef long double ld; typedef vector vi; typedef vector vll; typedef pair pii; typedef vector vvi; typedef vector vpii; typedef vector vs; const int MAXN = 1e5 + 9; const int MOD = (int)(1e9 + 7); const int INF = 100500; int n; ll aa[MAXN]; void input() { cin >> n; for(int i = 0; i < n; i++) cin >> aa[i]; sort(aa, aa + n); ll ans = 0; ll pw = 1; for(int i = n - 1; i >= 0; i--) { ans += pw * aa[i]; pw *= 2; } cout << ans; } void solve() { } int main() { ios_base::sync_with_stdio(0); cin.tie(0); #ifdef LOCAL freopen("xxx.in", "r", stdin); freopen("xxx.out", "w", stdout); #else //freopen("xxx.in", "r", stdin); //freopen("xxx.out", "w", stdout); #endif input(); solve(); return 0; }