#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int N = 80, M = N * (N - 1) / 2, INF = 0x3f3f3f3f;
int ii[N + 2];
int dp[M + 1][N + 2], dq[M + 1][N + 2];
int main() {
  int n;
  cin >> n;
  int m = n * (n - 1) / 2;
  int k = 0;
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    if (a == 1) ii[++k] = i;
  }
  ii[k + 1] = n + 1;
  for (int d = 0; d <= m; d++)
    for (int i = 0; i <= n + 1; i++) dp[d][i] = INF;
  dp[0][0] = 0;
  for (int h = 1; h <= k + 1; h++) {
    for (int u = 0; u <= m; u++)
      for (int i = 0; i <= n + 1; i++) {
        int x = INF;
        int v = u - abs(i - ii[h]);
        if (v >= 0)
          for (int g = 0, j; (j = i - g - 1) >= 0; g++) {
            int y = dp[v][j] + g * (g - 1);
            if (x > y) x = y;
          }
        dq[u][i] = x;
      }
    for (int u = 0; u <= m; u++)
      for (int i = 0; i <= n + 1; i++) dp[u][i] = dq[u][i];
  }
  int x = INF;
  int y = (n - k) * (n - k - 1);
  for (int u = 0; u <= m; u++) {
    x = min(x, dp[u][n + 1]);
    cout << (y - x) / 2 << ' ';
  }
  cout << '\n';
  return 0;
}
