#include <bits/stdc++.h>
using namespace std;
int n, a[85], pos[85], tot = 0;
int f[82][3204], g[82][3204];
inline int cal(int x) { return x * (x - 1) / 2; }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    if (a[i] == 1) pos[++tot] = i;
  }
  int pre = n * (n - 1) / 2 - tot * (tot - 1) / 2 - tot * (n - tot);
  int hf = n * (n - 1) / 2;
  if (tot == 0) {
    for (int i = 0; i <= hf; ++i) printf("0 ");
    return 0;
  }
  memset(f, 0x3f, sizeof(f));
  f[0][0] = 0;
  for (int i = 1; i <= tot; ++i) {
    memcpy(g, f, sizeof(f));
    memset(f, 0x3f, sizeof(f));
    for (int j = 1; j <= n; ++j) {
      int c = abs(pos[i] - j);
      for (int k = c; k <= hf; ++k)
        for (int t = 0; t < j; ++t) {
          f[j][k] = min(f[j][k], g[t][k - c] + cal(j - t - 1));
        }
    }
  }
  int ans = 0;
  for (int k = 0; k <= hf; ++k) {
    int res = 0x3f3f3f3f;
    for (int j = 1; j <= n; ++j)
      res = min(res, f[j][k] + (n - j) * (n - j - 1) / 2);
    ans = max(ans, pre - res);
    printf("%d ", ans);
  }
  return 0;
}
