#include using namespace std; typedef long long ll; #define rep(i,n) for(int i=0;iP; int main(){ int n; cin>>n; int a[n]; rep(i,n) cin>>a[i]; sort(a,a+n); int cnt=1; int temp=cnt; int f=0; int ans=0; for(int i=n-1;i>=0;i--){ ans+=(a[i]*f); temp--; if(temp==0){ cnt*=2; temp=cnt; f++; } } cout<