#include <bits/stdc++.h>
using namespace std;
vector<long long> v;
long long get_n(long long x) {
  long long cnt = 0;
  while (x) {
    ++cnt;
    x /= 4;
  }
  return cnt;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long all;
  cin >> all;
  v.resize(all + 1);
  for (int i = 1; i <= all; ++i) {
    cin >> v[i];
  }
  sort(v.begin() + 1, v.end(), greater<long long>());
  long long n = get_n(all);
  int i = 1, j = 1;
  long long ans = 0;
  while (j < v.size()) {
    ans += (accumulate(v.begin() + j, v.begin() + i + 1, 0LL) * n);
    j = i + 1, i *= 4, --n;
  }
  cout << ans << '\n';
  return 0;
}
