#include <bits/stdc++.h>
using namespace std;
const int N = 81;
int a[N], x = 0, y = 0, n, dp[N][N][N * N];
vector<int> v;
int f(int i, int j, int r) {
  if (!j) return 0;
  if (~dp[i][j][r]) return dp[i][j][r];
  int idx = n - i - j + 1, idy = x - j, res = 0;
  for (int k = 0; k <= i; k++)
    if (abs(idx + k - v[idy]) <= r) {
      res = max(res, k * (i - k) + f(i - k, j - 1, r - abs(idx + k - v[idy])));
    }
  return dp[i][j][r] = res;
}
int32_t main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    x += a[i];
    y += a[i] ^ 1;
    if (a[i]) v.push_back(i);
  }
  memset(dp, -1, sizeof dp);
  for (int i = 0; i <= n * (n - 1) / 2; i++)
    cout << f(y, x, i) << " \n"[i == n * (n - 1) / 2];
}
