#include <bits/stdc++.h>
using namespace std;
const int maxn = 80 + 5;
int n, a[maxn], num0, num1;
int dp[maxn][maxn][maxn * maxn];
int ans[maxn * maxn], pos[maxn];
inline int cal(int x) { return x * (x - 1) / 2; }
signed main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
    num1 += a[i];
    num0 += !a[i];
  }
  for (int i = 1, j = 0; i <= n; i++) {
    if (a[i] == 0) continue;
    j++;
    pos[j] = i;
  }
  memset(dp, 127, sizeof(dp));
  dp[0][0][0] = 0;
  for (register int i = 1; i <= num1; ++i) {
    for (register int j = 1; j <= n; ++j) {
      int c = abs(pos[i] - j);
      int mx = max(j * (j - 1) / 2, pos[i] * (pos[i] - 1) / 2);
      int mi = min(mx, n * (n - 1) / 2);
      for (register int k = c; k <= mi; ++k) {
        for (register int t = 0; t < j; ++t) {
          dp[i][j][k] = min(dp[i][j][k], dp[i - 1][t][k - c] + cal(j - t - 1));
        }
      }
    }
  }
  for (int j = 1; j <= n; j++)
    for (int k = 0; k <= n * (n - 1) / 2; k++)
      ans[k] = max(ans[k], num0 * (num0 - 1) / 2 - dp[num1][j][k] -
                               (n - j) * (n - j - 1) / 2);
  int ret = 0;
  for (int k = 0; k <= n * (n - 1) / 2; k++)
    printf("%d ", ret = max(ret, ans[k]));
}
