#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, nt;
  long long tmp;
  unsigned long long ans;
  vector<long long> A;
  vector<long long> pre;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> tmp;
    A.push_back(tmp);
  }
  sort(A.begin(), A.end());
  pre.push_back(A[0]);
  for (int i = 1; i < n; i++) {
    pre.push_back(A[i] + pre[i - 1]);
  }
  nt = n;
  ans = 0;
  while (nt > 0) {
    ans += pre[n - 1] - pre[n - nt] + A[n - nt];
    nt /= 4;
  }
  cout << ans << "\n";
  return 0;
}
