#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout.setf(ios::fixed);
  cout.setf(ios::showpoint);
  {
    long long int n;
    cin >> n;
    long long int a[n];
    for (long long int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n, greater<long long int>());
    long long int mul = 4 * n, ans = 0;
    while ((mul /= 4))
      for (long long int i = 0; i < mul; i++) ans += a[i];
    cout << ans;
  }
  return 0;
}
