#include <bits/stdc++.h>
using namespace std;
const int mxn = 82;
int n, m, k;
vector<int> v;
int dp[mxn][mxn][mxn * mxn];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    if (x) v.push_back(i);
  }
  v.push_back(++n);
  m = v.size(), k = (n - 1) * (n - 2) / 2;
  memset(dp, 0xcf, sizeof(dp));
  dp[0][0][0] = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < min(i, m); j++)
      for (int p = 0; p + abs(i - v[j]) <= k; p++) {
        int &dpc = dp[i][j + 1][p + abs(i - v[j])];
        if (dpc)
          for (int l = 0; l < i; l++) {
            dpc = max(dpc, dp[l][j][p] + (i - l - 1) * (l - j));
          }
      }
  cout << dp[n][m][0];
  for (int i = 1; i <= k; i++) {
    int &dpc = dp[n][m][i];
    dpc = max(dpc, dp[n][m][i - 1]);
    cout << " " << dpc;
  }
  cout << '\n';
  return 0;
}
