#include <bits/stdc++.h>
using namespace std;
const int N = 85;
int n, pos[N], a[N], f[N][N][N * N], tot;
signed main() {
  scanf("%d", &n);
  int c = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i]) pos[++c] = i;
  }
  tot = n * (n - 1) / 2 - c * (c - 1) / 2 - c * (n - c);
  if (c == 0) {
    for (int i = 0; i <= n * (n - 1) / 2; i++) printf("0 ");
    return 0;
  }
  memset(f, 0x3f, sizeof f);
  f[0][0][0] = 0;
  for (int i = 1; i <= c; i++)
    f[i][pos[i]][0] =
        f[i - 1][pos[i - 1]][0] +
        max(0, (pos[i] - pos[i - 1] - 1) * (pos[i] - pos[i - 1] - 2) / 2);
  for (int i = 1; i <= c; i++)
    for (int j = 1; j <= n; j++)
      for (int k = abs(pos[i] - j); k <= n * (n - 1) / 2; k++)
        for (int t = 0; t < j; t++)
          f[i][j][k] =
              min(f[i][j][k], f[i - 1][t][k - abs(pos[i] - j)] +
                                  max(0, (j - t - 1) * (j - t - 2) / 2));
  int ans = INT_MAX;
  for (int i = 0; i <= n * (n - 1) / 2; i++) {
    for (int j = 1; j <= n; j++)
      ans = min(ans, f[c][j][i] + max(0, (n - j) * (n - j - 1) / 2));
    printf("%d ", tot - ans);
  }
  return 0;
}
