#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2000010;
int n;
long long a[MAXN], sum[MAXN];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%I64d", &a[i]), a[i] = -a[i];
  sort(a + 1, a + n + 1);
  sum[0] = 0;
  for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i];
  int cur = 1;
  long long res = 0;
  while (cur <= n) {
    res += sum[cur];
    cur <<= 2;
  }
  cout << (-res) << endl;
}
