#include <bits/stdc++.h>
using namespace std;
long long v[2000005];
long long get_n(long long x) {
  long long cnt = 0;
  while (x) {
    ++cnt;
    x /= 4;
  }
  return cnt;
}
int main() {
  long long all;
  scanf("%I64d\n", &all);
  for (int i = 1; i <= all; ++i) {
    scanf(" %I64d", &v[i]);
  }
  sort(v + 1, v + all + 1, greater<long long>());
  long long n = get_n(all);
  int i = 1, j = 1;
  long long ans = 0;
  while (j <= all) {
    ans += (accumulate(v + j, v + i + 1, 0LL) * n);
    j = i + 1, i *= 4, --n;
  }
  printf("%I64d\n", ans);
  return 0;
}
