#include <bits/stdc++.h>
using namespace std;
double const eps = 1e-9;
int const INF = 1e9;
int const N = 2e6 + 16;
int const M = 1e9 + 7;
template <class t>
void sc(t& x) {
  x = 0;
  int c = 0, sign = 1, z = 0;
  while (!isdigit(c = getchar())) z = c;
  if (z == '-') sign = -1;
  do x = (x << 1) + (x << 3) + c - '0';
  while (isdigit(c = getchar()));
  x *= sign;
}
template <class t>
void put(t x) {
  static char buf[32];
  if (x == 0) {
    putchar('0');
    return;
  }
  if (x < 0) putchar('-'), x = -x;
  int i = 32;
  do buf[--i] = x % 10 + '0';
  while (x /= 10);
  while (i < 32) putchar(buf[i++]);
}
int n;
int a[N];
int main() {
  sc(n);
  int p = __builtin_ctz(n) >> 1;
  long long sum = 0;
  for (int i = 0; i < n; ++i) {
    int x;
    sc(x);
    a[i] = x;
  }
  sort(a, a + n, greater<int>());
  while (n) {
    for (int i = 0; i < n; ++i) sum += a[i];
    n >>= 2;
  }
  put(sum);
}
