/****************************************** * AUTHOR: BHUVNESH JAIN * * INSTITUITION: BITS PILANI, PILANI * ******************************************/ #include using namespace std; typedef long long LL; typedef long double LD; typedef pair pii; typedef pair pll; int a[10000]; int main() { #ifndef ONLINE_JUDGE //freopen("inp.txt", "r", stdin); #endif int n; scanf("%d", &n); long long ans = 0; long long p2 = 1; for(int i = 1; i <= n; ++i) { scanf("%d", &a[i]); } sort(a + 1, a + n + 1); for(int i = n; i >= 1; --i) { int x = a[i]; ans += p2 * x; p2 *= 2; } printf("%lld\n", ans); return 0; }