#include <bits/stdc++.h>
using namespace std;
int dx[] = {+1, -1, 0, 0};
int dy[] = {0, 0, +1, -1};
int n;
int a[82];
int dp[802][82][82];
int cnt[2][82];
int pos[2][82];
int tot[2];
int ans[3200];
int process(int moves, int zeros, int ones) {
  int &ret = dp[moves][zeros][ones];
  if (ret != -1) return ret;
  if (zeros + ones > n) return 0;
  int cur;
  if (max(pos[0][zeros], pos[1][ones]) == zeros + ones)
    cur = a[zeros + ones + 1];
  else if (pos[0][zeros] > pos[1][ones])
    cur = 1;
  else
    cur = 0;
  int res = 0;
  if (cur == 1) res = process(moves, zeros, ones + 1);
  int lagbe = 0;
  for (int i = zeros + 1; i <= tot[0]; i++) {
    int now;
    if (max(pos[0][i - 1], pos[1][ones]) == i + ones - 1)
      now = a[i + ones];
    else if (pos[0][i - 1] > pos[1][ones])
      now = 1;
    else
      now = 0;
    if (now) lagbe += (pos[0][i] - (i + ones));
    if (lagbe > moves) break;
    if (now) {
      res = max(res, process(moves - lagbe, i, ones + 1) + (i - zeros) * zeros);
    } else if (ones < tot[1]) {
      int special = lagbe + pos[1][ones + 1] - (i + ones + 1);
      if (special <= moves)
        res = max(res,
                  process(moves - special, i, ones + 1) + (i - zeros) * zeros);
    } else if (i + ones == n) {
      res = max(res, process(moves - lagbe, i, ones + 1) + (i - zeros) * zeros);
    }
  }
  return ret = res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  memset(dp, -1, sizeof(dp));
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  a[n + 1] = 1;
  for (int i = 1; i <= n; i++) {
    tot[a[i]]++;
    pos[a[i]][tot[a[i]]] = i;
    cnt[a[i]][i]++;
    cnt[0][i] += cnt[0][i - 1];
    cnt[1][i] += cnt[1][i - 1];
  }
  int mx = min(((n * (n - 1)) / 2), 800);
  for (int i = 0; i <= mx; i++) {
    ans[i] = process(i, 0, 0);
  }
  for (int i = 0; i <= (n * (n - 1)) / 2; i++) {
    if (i <= mx)
      cout << ans[i] << " ";
    else
      cout << ans[mx] << " ";
  }
  return 0;
}
