#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int m = 0;
  while (n /= 4) {
    m++;
  }
  int w = m + 1;
  long long ans = 0;
  int t = 1;
  for (int i = 0; i < (int)a.size(); i++) {
    ans += (long long)w * a[i];
    if (i + 1 == t) {
      t *= 4;
      w--;
    }
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}
