#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
template <class T>
ostream& operator<<(ostream& os, vector<T> V) {
  os << "[ ";
  for (auto v : V) os << v << " ";
  return os << "]";
}
template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
template <typename T, typename U>
pair<T, U> operator+(const pair<T, U>& l, const std::pair<T, U>& r) {
  return {l.first + r.first, l.second + r.second};
}
const long long int mod = 1e9 + 7;
const int maxn = 81;
int dp[maxn][maxn][maxn * maxn];
int n, cnt1;
int a[maxn];
vector<int> ones;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i], cnt1 += a[i];
  for (int i = 0; i < n; i++) {
    if (a[i] == 1) ones.push_back(i);
  }
  if (cnt1 == 0 || cnt1 == n) {
    for (int i = 0; i <= (n * (n - 1)) / 2; i++) {
      cout << 0 << " ";
    }
    return 0;
  }
  int last0, rem0, onth, cost;
  for (int i = n - 1; i >= 0; i--)
    for (int rem = 1; rem <= min(cnt1, n - i); rem++)
      for (int can = 0; can <= (n * (n - 1)) / 2; can++) {
        if (n - i == rem) continue;
        for (int j = i; j < n; j++) {
          cost = abs(j - ones[cnt1 - rem]);
          if (can >= cost and rem > 0) {
            dp[i][rem][can] =
                max(dp[i][rem][can],
                    dp[j + 1][rem - 1][can - cost] +
                        (j - i) * ((n - cnt1) - (j - (cnt1 - rem))));
          }
        }
      }
  for (int i = 0; i <= (n * (n - 1)) / 2; i++) {
    cout << dp[0][cnt1][i] << " ";
  }
}
