#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
vector<long long int> A, pre;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    long long int u;
    scanf("%lld", &u);
    A.push_back(u);
  }
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  long long int s = 0;
  for (int i = 0; i < n; i++) {
    s += A[i];
    pre.push_back(s);
  }
  long long int i = 1;
  long long int s2 = 0;
  while (i <= n) {
    s2 += pre[i - 1];
    i *= 4;
  }
  printf("%lld", s2);
  return 0;
}
