#include using namespace std; typedef long long ll; #define int ll #define endl '\n' #define pii pair #define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define pb push_back #define pii pair #define F first #define S second #define M_PI 3.14159265358979323846 const int mod = 1000000007; const int MAXX = 1e6 + 5; int n; signed main() { _FastIO; cin >> n; vector a(n); for(int i = 0; i < n; i++){ cin >> a[i]; } sort(a.rbegin() , a.rend()); int ans = 0; for(int i = 0; i < n; i++){ int k = log2(i + 1); ans += (k * a[i]); } cout << ans << endl; return 0; }