#include <bits/stdc++.h>
using namespace std;
const int TURNS = 1605;
int n;
vector<int> pos[2];
int dp[81][81][TURNS];
int get_turns(int w, int b) {
  assert(pos[0].size() + pos[1].size() >= w + b);
  int i = pos[0].size() + pos[1].size() - w - b;
  assert(pos[1].size() >= b);
  int bp = pos[1].size() - b;
  int j = pos[1][bp];
  return abs(i - j);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    pos[x].push_back(i);
  }
  for (int i = 0; i <= n * (n - 1) / 2; ++i) {
    int turns = min(i, TURNS);
    for (int b = 0; b < pos[1].size(); ++b) {
      dp[0][b][turns] = 0;
    }
    for (int w = 0; w < pos[0].size(); ++w) {
      dp[w][0][turns] = 0;
    }
    for (int w = 1; w <= pos[0].size(); ++w) {
      for (int b = 1; b <= pos[1].size() && w + b <= n; ++b) {
        int &ans = dp[w][b][turns];
        for (int use = 0; use <= w; ++use) {
          int new_turns = turns - get_turns(w - use, b);
          if (new_turns >= 0) {
            ans = max(ans, use * (w - use) + dp[w - use][b - 1][new_turns]);
          }
        }
      }
    }
    cout << dp[pos[0].size()][pos[1].size()][turns] << " ";
  }
  cout << "\n";
}
