#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> V;
  for (int i = 0; i < n; ++i) {
    long long val;
    cin >> val;
    V.push_back(val);
  }
  sort(V.rbegin(), V.rend());
  long long s = 0;
  while (n > 0) {
    for (int i = 0; i < n; ++i) s += V[i];
    n /= 4;
  }
  cout << s;
  return 0;
}
