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