#include <bits/stdc++.h>
using namespace std;
const int N = 81;
const int inf = 1e9;
int n, c, a[N];
int dp[N][N][N * N];
vector<int> vc;
int main() {
  scanf("%d", &n);
  c = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    c += a[i];
    if (a[i]) vc.push_back(i);
  }
  int m = n * (n - 1) / 2;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= c; j++) {
      for (int k = 0; k <= m; k++) {
        dp[i][j][k] = (j == 0 && k == 0) ? 0 : -inf;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= c; j++) {
      for (int k = 0; k <= m; k++) {
        if (j > i) continue;
        int tmp = vc[j - 1];
        for (int p = 1; p <= i; p++) {
          int ops = abs(tmp - p);
          if (k < ops) continue;
          dp[i][j][k] =
              max(dp[i][j][k], dp[p - 1][j - 1][k - ops] + (p - j) * (i - p));
        }
      }
    }
  }
  int mx = -inf;
  for (int i = 0; i <= n * (n - 1) / 2; i++) {
    mx = max(mx, dp[n][c][i]);
    printf("%d ", mx);
  }
  printf("\n");
}
