#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, mod = 1e9 + 7;
int main() {
  int tc = 1;
  for (int cn = 1; cn <= tc; cn++) {
    int n;
    scanf("%d", &n);
    vector<int> v(n);
    for (int &x : v) scanf("%d", &x);
    int mxCost = (n * n + 2 * n + 1) / 4;
    vector<int> id;
    for (int i = 0; i < n; i++) {
      if (v[i]) id.push_back(i);
    }
    int ones = (int)id.size();
    vector<vector<vector<int>>> dp(
        ones + 1, vector<vector<int>>(n, vector<int>(mxCost, -1e9)));
    for (int lst = 0; lst < n && ones; lst++) {
      if (abs(lst - id[0]) < mxCost) {
        dp[1][lst][abs(lst - id[0])] = (n - lst - 1) * lst;
      }
    }
    for (int put = 2; put <= ones; put++) {
      for (int lst = put - 1; lst < n; lst++) {
        for (int newCost = abs(lst - id[put - 1]); newCost < mxCost;
             newCost++) {
          int cost = newCost - abs(lst - id[put - 1]);
          for (int j = 0; j < lst; j++) {
            dp[put][lst][newCost] = max(dp[put][lst][newCost],
                                        dp[put - 1][j][cost] - (j - put + 2) +
                                            (n - lst - 1) * (lst - j - 1));
          }
        }
      }
    }
    int curMx = 0;
    for (int c = 0; c <= n * (n - 1) / 2; c++) {
      int mx = curMx;
      for (int l = max(0, ones - 1); l < n; l++)
        mx = max(mx, dp[ones][l][min(c, mxCost - 1)]);
      printf("%d ", mx);
      curMx = max(mx, curMx);
    }
  }
  return 0;
}
