#include <bits/stdc++.h>
using namespace std;
const int N = 82;
int a[N], dp[N][N][N * N], n;
vector<int> f;
int32_t main() {
  scanf("%d", &n);
  int c0 = 0, c1 = 0;
  int cur = 0;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    if (x == 1) {
      f.push_back(cur);
      cur = 0;
      c1++;
    } else
      cur++, c0++;
  }
  f.push_back(cur);
  a[0] = 0;
  for (int i = 1; i <= (int)(f).size(); i++) {
    a[i] = a[i - 1] + f[i - 1];
  }
  int ans = c0 * c0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < N * N; k++) dp[i][j][k] = (int)1e9;
    }
  }
  dp[0][0][0] = 0;
  for (int i = 1; i <= (int)(f).size(); i++) {
    for (int j = 0; j <= c0; j++) {
      for (int k = 0; k <= n * (n - 1) / 2; k++) {
        for (int t = 0; t <= j; t++) {
          if (k >= abs(a[i] - j)) {
            dp[i][j][k] =
                min(dp[i][j][k], dp[i - 1][j - t][k - abs(a[i] - j)] + t * t);
          }
        }
      }
    }
  }
  int mx = (int)1e10;
  for (int k = 0; k <= n * (n - 1) / 2; k++) {
    mx = min(mx, dp[(int)(f).size()][c0][k]);
    printf("%d ", (ans - mx) / 2);
    ;
  }
}
