#include <bits/stdc++.h>
using namespace std;
int t(int n, int k) {
  int x = 1;
  int p = k;
  while (p <= n) {
    p = k;
    p = p + x;
    x = x * 2;
  }
  p = p - x / 2 + x / 4;
  return p;
}
int main() {
  unsigned int a;
  cin >> a;
  unsigned int b[a + 1];
  unsigned int i = 1;
  for (i = 1; i <= a; i++) {
    cin >> b[i];
  }
  unsigned int n = a, tmp, k = 0;
  i = 1;
  while (i < n) {
    tmp = t(n, i);
    {
      while (b[i] != 0) {
        b[i] = b[i] - 1;
        b[tmp] = b[tmp] + 1;
        k++;
      }
      cout << k << endl;
    }
    i++;
  }
  if ((a == 0) || (a == 1)) cout << endl;
  return 0;
}
