#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  unsigned long long n;
  cin >> n;
  unsigned long long k = n;
  vector<unsigned long long> S;
  while (k--) {
    unsigned long long l;
    cin >> l;
    S.push_back(l);
  }
  sort(S.begin(), S.end(), greater<int>());
  unsigned long long res = 0, cumsum = 0, pow4 = 1;
  for (unsigned long long int i = 0; i < S.size(); i++) {
    cumsum += S[i];
    if (pow4 == i + 1) {
      res += cumsum;
      pow4 <<= 2;
    }
  }
  cout << res << "\n";
  return 0;
}
