#include <bits/stdc++.h>
using namespace std;
int dp[82][82][3200], n;
vector<int> wh;
bool vis[82][82][3200];
int solve(int did, int pre, int amop) {
  if (amop < 0 || n - pre < int(wh.size()) - did) return -1e9;
  if (did == int(wh.size())) {
    if (int(wh.size()) == 0) return 0;
    int am0 = pre + 1 - did;
    return am0 * (n - pre - 1);
  }
  int &r = dp[did][pre][amop];
  if (vis[did][pre][amop]) return r;
  vis[did][pre][amop] = 1;
  r = -1e9;
  for (int i = pre + (did != 0), ThxDem = n; i < ThxDem; ++i) {
    if (n - i - 1 < int(wh.size()) - did - 1) break;
    if (i - wh[did] > amop) break;
    if (wh[did] - i > amop) continue;
    int now = 0;
    if (did) {
      int he = pre + 1 - did;
      int me = i - pre - 1;
      now = he * me;
    }
    r = max(r, now + solve(did + 1, i, amop - abs(wh[did] - i)));
  }
  return r;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  vector<int> a(n);
  for (int i = 0, ThxDem = n; i < ThxDem; ++i) {
    cin >> a[i];
    if (a[i]) wh.push_back(i);
  }
  for (int i = 0, ThxDem = n * (n - 1) / 2 + 1; i < ThxDem; ++i)
    cout << solve(0, 0, min(1610, i)) << " ";
  cout << "\n";
}
