#include <bits/stdc++.h>
using namespace std;
const int MAXN = 90;
const int INF = 0x3f3f3f3f;
inline int read() {
  int n = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -f;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    n = 10 * n + (c ^ '0');
    c = getchar();
  }
  return f * n;
}
int a[MAXN], total;
int dp[MAXN][MAXN][MAXN * MAXN];
int main() {
  int n = read(), m = n * (n - 1) / 2;
  for (int i = 1; i <= n; i++) {
    if (read() == 1) {
      a[++total] = i;
    }
  }
  if (total == 0) {
    for (int i = 0; i <= m; i++) {
      printf("%d ", 0);
    }
    return 0;
  }
  memset(dp, INF, sizeof(dp));
  dp[0][0][0] = 0;
  for (int i = 1; i <= total; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 0; k < j; k++) {
        for (int o = 0; o <= m; o++) {
          int p = o + abs(a[i] - j);
          if (p > m) continue;
          int q = j - k - 1;
          int t = min(dp[i][j][p - 1], dp[i - 1][k][o] + q * (q - 1) / 2);
          if (t < dp[i][j][p]) dp[i][j][p] = t;
        }
      }
    }
  }
  int tmp = m - total * (total - 1) / 2 - total * (n - total);
  for (int k = 0; k <= m; k++) {
    int ans = INF;
    for (int j = 1; j <= n; j++) {
      int q = n - j;
      ans = min(ans, dp[total][j][k] + q * (q - 1) / 2);
    }
    printf("%d ", tmp - ans);
  }
  return 0;
}
