#include using namespace std; #define maxn 42 #define FOR(i, l, r) for (int i=l; i<=r; ++i) #define FORD(i, r, l) for (int i=r; i>=l; --i) #define fi first #define se second #define mk make_pair #define nil NULL #define y0 y902 #define y1 y232 #define x0 x92 #define x1 x899 #define next asdfa typedef long long ll; typedef double db; typedef pair dd; typedef pair ii; typedef vector vi; const int inf = 1e9; template int getbit(T x, int pos) {return (x>>(pos-1)) & 1;} template void turn_on(T &x, int pos) {x = x | ((T)1<<(pos-1));} template void turn_off(T &x, int pos) {x = x & ~((T)1<<(pos-1));} template T sqr(T a) {return a*a;} int len(string a) {return (int)a.length();} int a[maxn]; ll POW(int n, int k) { if (k==0) return 1; ll tmp = POW(n, k/2); if (k%2==0) return tmp*tmp; return tmp*tmp*ll(n); } bool cmp(int a, int b) {return a>b;} int main() { // freopen("input.in", "r", stdin); ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; FOR(i, 0, n-1) cin >> a[i]; sort(a, a+n, cmp); ll res = 0; FOR(i, 0, n-1) res += POW(2, i)*(ll)a[i]; cout << res; }