#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long sum = 0;
  int a[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  sort(a, a + n);
  reverse(a, a + n);
  for (int i = 1; i <= n; i = i * 4) {
    for (int j = 0; j < i; j++) {
      sum = sum + a[j];
    }
  }
  cout << sum << endl;
}
