#include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main(void){ int n; cin >> n; int a[n]; rep(i,n) cin >> a[i]; sort(a,a+n); reverse(a,a+n); long ans = 0; rep(i,n){ int k = i+1,now=-1; while(k>0){ k /= 2; now++; } ans += a[i]*now; } cout << ans << endl; }