#include <bits/stdc++.h>
using namespace std;
vector<int, int> &getVector(const unordered_map<long long, int> &trad,
                            vector<map<int, int>> &g, int dst, int &prox,
                            long long res, int v, int i);
template <class C>
void mini(C &a, C b) {
  a = min(a, b);
}
template <class C>
void maxi(C &a, C b) {
  a = max(a, b);
}
void e() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<int> pos = {0};
  int unos = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == 1)
      unos++;
    else
      pos.push_back(unos);
  }
  int ceros = n - unos;
  int maxmov = n * (n - 1) / 2;
  vector<vector<vector<int>>> dp(
      ceros + 1, vector<vector<int>>(unos + 2, vector<int>(maxmov + 1, 1e9)));
  for (int j = 0; j < unos + 2; j++)
    for (int mov = 0; mov < maxmov + 1; mov++) dp[0][j][mov] = 0;
  for (int(i) = 1; i <= ceros; i++) {
    for (int(j) = 1; j <= unos + 1; j++) {
      for (int mov = 0; mov < maxmov + 1; mov++) {
        int movp = mov;
        int ip = i;
        while (movp >= 0 and ip >= 0) {
          mini(dp[i][j][mov],
               dp[ip][j - 1][movp] + (i - ip) * (i - ip - 1) / 2);
          movp -= abs(pos[ip] - (j - 1));
          ip--;
        }
      }
    }
  }
  vector<int> res(maxmov + 1);
  for (int mov = 0; mov < maxmov + 1; mov++)
    res[mov] = dp[ceros][unos + 1][mov];
  for (int(mov) = 1; mov <= maxmov; mov++) mini(res[mov], res[mov - 1]);
  for (int mov = 0; mov < maxmov + 1; mov++)
    res[mov] = ceros * (ceros - 1) / 2 - res[mov];
  for (auto r : res) cout << r << ' ';
  cout << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  e();
  return 0;
}
