#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define f first #define s second #define pb push_back #define pp pop_back #define mp make_pair #define ll long long #define ld double #define ull unsigned long long #define PI pair < ll, ll > const int N = 2002; const int M = 123; const ld Pi = acos(-1); const ll Inf = 1e18; const int inf = 1e9; const int mod = 1e9 + 7; void add(int &a, int b) { a += b; if (a >= mod) a -= mod; } int mult(int a, int b) { return 1ll * a * b % mod; } int n, a[N]; ll ans; int main() { #ifdef wws freopen("in", "r", stdin); // freopen("out", "w", stdout); #endif ios_base::sync_with_stdio(0); cin >> n; for (int i = 0;i < n;i++) { cin >> a[i]; } sort(a, a + n); reverse(a, a + n); for (int i = 0;i < n;i++) { ans += 1ll * a[i] * (1ll << i); } cout << ans << endl; return 0; }