#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template <class T>
bool ckmin(T& a, const T& b) {
  return a > b ? a = b, 1 : 0;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, 1 : 0;
}
template <class T>
T gcd(T a, T b) {
  return b != T(0) ? gcd(b, a % b) : a;
}
const int N = 90, inf = 1e9;
int a[N];
int dp[N][N][N * N];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  for (auto i = (0); i < (n); ++i) cin >> a[i];
  vector<int> x;
  for (int i = 0, j = 0; i <= n; i = ++j) {
    while (j < n && !a[j]) ++j;
    x.emplace_back(j - i);
  }
  int z = int((x).size());
  for (auto i = (1); i < (z); ++i) x[i] += x[i - 1];
  for (auto i = (0); i < (N); ++i)
    for (auto j = (0); j < (N); ++j)
      for (auto s = (0); s < (N * N); ++s) dp[i][j][s] = inf;
  dp[0][0][0] = 0;
  int t = n - z + 1;
  for (auto i = (0); i < (z); ++i)
    for (auto j = (0); j < (t + 1); ++j)
      for (auto s = (0); s < (n * (n - 1) / 2 + 1); ++s)
        for (auto k = (j); k < (t + 1); ++k)
          ckmin(dp[i + 1][k][s + abs(k - x[i])],
                dp[i][j][s] + (k - j) * (k - j));
  int mn = inf;
  for (auto s = (0); s < (n * (n - 1) / 2 + 1); ++s) {
    ckmin(mn, dp[z][t][s]);
    cout << (t * t - mn) / 2 << ' ';
  }
}
