#include <bits/stdc++.h>
using namespace std;
long long int arr[2000003], n;
long long int i, j, k = 1, l;
long long int top;
int main() {
  scanf("%lld", &n);
  for (i = 1; i <= n; i++) {
    scanf("%lld", &arr[i]);
  }
  sort(arr + 1, arr + n + 1);
  k = n;
  while (k) {
    for (i = n; i >= n - k + 1; i--) top += arr[i];
    k /= 4;
  }
  printf("%lld", top);
  return 0;
}
