#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 0x3f3f3f3f;
const int maxn = 81;
const int mod = 1e9 + 7;
int n, a[maxn];
int dp[maxn][maxn][3200];
int pos[maxn], N, sum, sum1;
int ans[maxn * maxn];
void MAX(int &x, int y) {
  if (x < y) x = y;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] == 0) sum++;
    if (a[i] == 1) pos[++N] = i;
  }
  int g = n * (n - 1) / 2;
  memset(dp, -inf, sizeof dp);
  dp[0][0][0] = 0;
  for (int i = 1; i <= N; i++) {
    for (int j = i; j <= n - (N - i); j++) {
      int d = abs(pos[i] - j), x = j - i;
      if (sum - x < 0) continue;
      x = sum - x;
      for (int k = d; k <= g; k++) {
        for (int f = i - 1; f <= j - 1; f++) {
          MAX(dp[i][j][k], dp[i - 1][f][k - d] + (j - f - 1) * x);
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i <= g; i++) {
    for (int j = N; j <= n; j++) MAX(ans, dp[N][j][i]);
    cout << ans << " ";
  }
  return 0;
}
