#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
long long A[2000005];
long long B[1000005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long tst = 1;
  for (long long tt = 1; tt <= tst; tt++) {
    long long n, val, res = 0;
    cin >> n;
    val = n;
    for (long long i = 1; i <= n; i++) cin >> A[i];
    sort(A + 1, A + n + 1, greater<long long>());
    for (long long i = 1; i <= n; i++) A[i] += A[i - 1];
    while (val) {
      res += A[val];
      val /= 4;
    }
    cout << res << endl;
  }
  return 0;
}
