#include <bits/stdc++.h>
#pragma GCC optimize("O3", "Ofast", "unroll-loops", "omit-frame-pointer", \
                     "inline")
#pragma GCC option("arch=native", "tune=native", "no-zero-upper")
using namespace std;
const long long MAXN = 82;
long long A[MAXN];
long long dp[MAXN][MAXN][MAXN * (MAXN - 1) / 2];
long long B[MAXN];
long long pt = 1;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  for (long long i = 0; i < MAXN; i++) {
    for (long long j = 0; j < MAXN; j++) {
      for (long long k = 0; k < MAXN * (MAXN - 1) / 2; k++) {
        dp[i][j][k] = -1e18;
      }
    }
  }
  long long N;
  cin >> N;
  long long cont = 0;
  for (long long i = 1; i <= N; i++) {
    cin >> A[i];
    if (A[i] == 1) {
      B[pt] = i;
      pt++;
      cont++;
    }
  }
  B[pt] = N + 1;
  dp[0][0][0] = 0;
  for (long long i = 1; i <= N + 1; i++) {
    for (long long j = 1; j <= cont + 1; j++) {
      for (long long k = N * (N - 1) / 8 + 2; k >= 0; k--) {
        long long val = k - abs(i - B[j]);
        if (val < 0) break;
        for (long long x = 0; x < i; x++) {
          dp[i][j][k] =
              max(dp[i][j][k], dp[x][j - 1][val] + (x - (j - 1)) * (i - x - 1));
        }
      }
    }
  }
  long long temp = 0;
  for (long long i = 0; i <= N * (N - 1) / 2; i++) {
    cout << max(dp[N + 1][cont + 1][i], temp) << " ";
    temp = max(temp, dp[N + 1][cont + 1][i]);
  }
  return 0;
}
