#include <bits/stdc++.h>   using namespace std;   void chekarre(int* arr, int n) {     cout <<  [ ;     for (int i = 0; i < n; i++) cout << arr[i] <<    ;     cout <<  ]  << endl;   }   bool comp(int i, int j) { return (i > j); }   int a[2000007];   int main() {     int n;     long long sum = 0;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];     }     sort(a, a + n);     reverse(a, a + n);     while (n) {       for (int j = 0; j < n; j++) {         sum += a[j];       }       n = n / 4;     }     cout << sum << endl;     return 0;   }   