#include <bits/stdc++.h>
using namespace std;
using big = long long;
const int N = 82;
int f[N][N][N * (N - 1) / 2 + 10];
int n;
int a[N], idx[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  int cnt1 = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    cnt1 += a[i];
    if (a[i]) {
      idx[cnt1] = i;
    }
  }
  int m = n * (n - 1) / 2;
  memset(f, 0x3f, sizeof(f));
  const int inf = 0x3f3f3f3f;
  f[0][0][0] = 0;
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j < cnt1; ++j) {
      for (int k = 0; k <= m; ++k) {
        if (f[i][j][k] < inf) {
          for (int nxt = i + 1; nxt <= n; ++nxt) {
            int steps = std::abs(nxt - idx[j + 1]);
            if (steps + k <= m) {
              int cost = max(nxt - i - 1, 0) * max(nxt - i - 2, 0) / 2;
              if (j + 1 == cnt1) {
                cost += (n - nxt) * (n - nxt - 1) / 2;
              }
              f[nxt][j + 1][k + steps] =
                  min(f[nxt][j + 1][k + steps], f[i][j][k] + cost);
            }
          }
        }
      }
    }
  }
  int cnt0 = n - cnt1;
  for (int i = 0; i <= m; ++i) {
    int ans = inf;
    for (int j = 1; j <= n; ++j) {
      if (i) {
        f[j][cnt1][i] = min(f[j][cnt1][i], f[j][cnt1][i - 1]);
      }
      ans = min(ans, f[j][cnt1][i]);
    }
    if (!cnt1) {
      cout << 0 << " ";
    } else {
      cout << (cnt0 * (cnt0 - 1) / 2 - ans) << " ";
    }
  }
  return 0;
}
