#include <bits/stdc++.h>
using namespace std;
long long a[2000010];
int main() {
  int m;
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) scanf("%I64d", &a[i]);
  int x = m;
  int n = 0;
  while (x > 1) {
    x /= 4;
    n++;
  }
  sort(a + 1, a + m + 1);
  reverse(a + 1, a + m + 1);
  long long ans = (n + 1) * a[1];
  for (int i = 2; i <= m; i++) {
    int k = 0;
    int j = i;
    int z = 1;
    while (j > z) {
      z *= 4;
      k++;
    }
    ans += (n - k + 1) * a[i];
  }
  printf("%I64d", ans);
  return 0;
}
