#include <bits/stdc++.h>
using namespace std;
int main() {
  int l;
  scanf("%d", &l);
  int a[2000000];
  long long cont = 0;
  int tot = l;
  for (int i = 0; i < l; i++) {
    scanf("%d", &a[i]);
    a[i] = -a[i];
  }
  while (l != 1) {
    l /= 4;
    cont++;
  }
  sort(a, a + tot);
  long long ans = 0;
  ans += (long long)(-a[0] * (cont + 1));
  cont--;
  tot--;
  int base = 3;
  int ac = 1;
  while (tot > 0) {
    for (int i = ac; i < ac + base; i++) ans += (long long)(-a[i] * (cont + 1));
    ac += base;
    cont--;
    tot -= base;
    base *= 4;
  }
  cout << ans << endl;
  return 0;
}
