#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int f = 1, x = 0;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
  return x * f;
}
const int N = 85;
int n, m, a[N], s[N];
int F[N][N][N * N], ans[N * N];
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    a[i] = read();
    if (a[i]) s[++m] = i;
  }
  memset(F, 0xcf, sizeof(F));
  F[0][0][0] = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= min(i, m); j++)
      for (int k = 0; k <= n * (n - 1) / 2; k++) {
        if (k - abs(s[j] - i) < 0) continue;
        for (int l = 0; l <= i - 1; l++)
          if (l - j + 1 >= 0)
            F[i][j][k] = max(F[i][j][k], F[l][j - 1][k - abs(s[j] - i)] +
                                             (l - j + 1) * (i - l - 1));
      }
  memset(ans, 0xcf, sizeof(ans));
  for (int k = 0; k <= n * (n - 1) / 2; k++) {
    if (k) ans[k] = ans[k - 1];
    for (int i = m; i <= n; i++)
      ans[k] = max(ans[k], F[i][m][k] + (n - i) * (i - m));
    printf("%d ", ans[k]);
  }
  puts("");
  return 0;
}
