#include <bits/stdc++.h>
using namespace std;
int a[2000010];
bool cmp(const int a, const int b) { return a > b; }
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    for (int i = 0; i < n; i++) {
      scanf("%d", &a[i]);
    }
    sort(a, a + n, cmp);
    int w = 1;
    int x = n;
    while (x > 1) {
      x /= 4;
      w++;
    }
    int m = 1;
    long long ans = 0;
    for (int i = 0; i < n; i++) {
      if (i == m) {
        m *= 4;
        w--;
      }
      ans += (long long)w * a[i];
    }
    cout << ans << endl;
  }
  return 0;
}
