#include <bits/stdc++.h>
using namespace std;
using INT = long long;
using pii = pair<INT, INT>;
int n;
const int NN = 2000011;
int a[NN];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
  }
  sort(a, a + n);
  reverse(a, a + n);
  int m = n;
  INT ans = 0;
  while (m >= 1) {
    for (int i = 0; i < m; i++) ans += a[i];
    m /= 4;
  }
  cout << ans << endl;
}
