#include <bits/stdc++.h>
using namespace std;
int a[2000010];
int c[2000010];
bool cmp(int x, int y) { return x > y; }
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + 1 + n, cmp);
  int m = n;
  int temp = 0;
  while (m) {
    temp++;
    m /= 4;
  }
  c[1] = temp;
  int last = 1;
  while (last < n) {
    int next = last * 4;
    for (int i = last + 1; i <= next; i++) c[i] = c[last] - 1;
    last = next;
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) ans += (long long)c[i] * (long long)a[i];
  printf("%I64d\n", ans);
  return 0;
}
