#include <bits/stdc++.h>
using namespace std;
long long a[2500000];
int main() {
  int all;
  scanf("%d", &all);
  for (int i = 1; i <= all; i++) {
    scanf("%I64d", &a[i]);
  }
  sort(a + 1, a + all + 1);
  reverse(a + 1, a + all + 1);
  long long sum = 0;
  for (int fro = 1; fro <= all; fro = fro << 2) {
    for (int p = 1; p <= fro; p++) {
      sum += a[p];
    }
  }
  long long temp = 0, area = 1;
  printf("%I64d", sum);
  return 0;
}
