#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n;
  scanf("%lld", &n);
  long long a[n + 1];
  for (long long i = 1; i <= n; i++) scanf("%lld", &a[i]);
  a[0] = 0;
  sort(a + 1, a + 1 + n, greater<long long>());
  for (long long i = 1; i <= n; i++) a[i] += a[i - 1];
  long long t = 1, ans = 0LL;
  while (t <= n) {
    ans += a[t];
    t *= 4;
  }
  printf("%lld\n", ans);
  return 0;
}
