#include <bits/stdc++.h>
using namespace std;
int n;
int arr[85];
int cache[80][2565][81];
int ans[4000];
int loc[85];
int cnt = 0;
const int inf = 0x3f3f3f3f;
int solve(int idx, int score, int b_cnt) {
  if (score < 0) return inf;
  if (idx == n) {
    if (b_cnt != 0) return inf;
    if (score == 0) return 0;
    return inf;
  }
  if (b_cnt == 0) return inf;
  int &ret = cache[idx][score][b_cnt];
  if (ret != -1) return ret;
  ret = inf;
  int now = abs(loc[b_cnt] - idx);
  int w_cnt = idx - (cnt - b_cnt);
  int r_cnt = n - idx - b_cnt;
  for (int i = 0; i <= r_cnt && idx + 1 + i <= n; i++) {
    ret = min(ret, solve(idx + 1 + i, score - w_cnt * i, b_cnt - 1) + now);
  }
  return ret;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
  }
  for (int i = n - 1; i >= 0; i--) {
    if (arr[i]) {
      cnt++;
      loc[cnt] = i;
    }
  }
  memset(cache, -1, sizeof(cache));
  for (int i = 0; i < 2565; i++) {
    int idx = inf;
    for (int j = 0; j <= n; j++) {
      idx = min(idx, solve(j, i, cnt));
    }
    if (idx != inf) {
      ans[idx] = max(ans[idx], i);
    }
  }
  for (int i = 0; i <= n * (n - 1) / 2; i++) {
    if (i) ans[i] = max(ans[i], ans[i - 1]);
    printf("%d ", ans[i]);
  }
  printf("\n");
  return 0;
}
