#include <bits/stdc++.h>
using namespace std;
int dp[82][82][82 * 82 / 2];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  srand(228);
  int n;
  cin >> n;
  vector<int> a(n);
  int sum = 0;
  vector<int> sumPr(n);
  vector<int> poss;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    sum += a[i];
    if (a[i]) poss.push_back(i);
    if (i) sumPr[i] = sumPr[i - 1];
    sumPr[i] += a[i];
  }
  for (int i = 0; i <= n; ++i) {
    for (int num = 0; num <= sum; ++num) {
      for (int e = 0; e <= n * (n + 1) / 2; ++e) dp[i][num][e] = (int)-1e9;
    }
  }
  dp[0][0][0] = 0;
  for (int i = 0; i < n; ++i) {
    for (int num = 0; num < sum; ++num) {
      for (int e = 0; e <= n * (n + 1) / 2; ++e) {
        if (dp[i][num][e] == (int)-1e9) continue;
        for (int pos = i; pos < n; ++pos) {
          int nw =
              (pos - i) * ((n - pos - 1) - (sum - num - 1)) + dp[i][num][e];
          dp[pos + 1][num + 1][e + abs(pos - poss[num])] =
              max(dp[pos + 1][num + 1][e + abs(pos - poss[num])], nw);
        }
      }
    }
  }
  int mx = 0;
  for (int e = 0; e <= n * (n - 1) / 2; ++e) {
    for (int j = 0; j <= n; ++j) mx = max(mx, dp[j][sum][e]);
    cout << mx << " ";
  }
  cout << "\n";
}
