#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
int MulMod(int a, int b) { return (a * b) % MOD; }
int AddMod(int a, int b) { return (a + b) % MOD; }
const int MAXN = 82;
int dp[MAXN][MAXN][(MAXN * MAXN) / 2];
int a[MAXN], zeroCnt, n;
vector<int> pos;
int getMoves(int id, int idx) { return abs(id - pos[idx]); }
int rec(int idx, int ones, int moves) {
  if (idx == n + 1) return 0;
  int &ans = dp[idx][ones][moves];
  if (ans != -1) return ans;
  if (ones == (int)pos.size()) {
    int piche = n - idx + 1;
    return ans = (zeroCnt - piche) * piche;
  } else {
    for (int j = (idx); j <= (n - ((int)pos.size() - ones) + 1); j++) {
      int move = getMoves(j, ones);
      if (move <= moves) {
        int val = j - idx;
        val = val * (zeroCnt - val);
        ans = max(ans, val + rec(j + 1, ones + 1, moves - move));
      }
    }
    return ans;
  }
}
void solving() {
  cin >> n;
  for (int i = (1); i <= (n); i++) {
    cin >> a[i];
    if (a[i] == 1)
      pos.emplace_back(i);
    else
      zeroCnt++;
  }
  memset((dp), (int)(-1), sizeof((dp)));
  for (int i = (0); i <= (n * (n - 1) / 2); i++)
    cout << rec(1, 0, i) / 2 << " ";
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t = 1;
  for (int i = (1); i <= (t); i++) {
    solving();
  }
}
