#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

int n;

signed main(){
    while(cin >> n, n){
        vector<int> t(n);
        rep(i, 0, n) cin >> t[i];
        sort(all(t));
        int ans = 0;
        rep(i, 0, n){
            ans += ans + t[i];
        }
        cout << ans << endl;
    }

}