#include <bits/stdc++.h>
using namespace std;
const int MAX = 1200010;
int n, a[MAX], h;
long long sum, result;
bool compare(int x, int y) { return (x > y); }
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + 1 + n, compare);
  h = 0;
  result = 0;
  sum = 0;
  int t = 1;
  for (int i = 1; i <= n; i++) {
    sum += a[i];
    if (t == i) {
      t *= 4;
      result += sum;
    }
  }
  cout << result;
}
