#include <bits/stdc++.h>
using namespace std;
int read() {
  char c = getchar();
  int flag = 1, ans = 0;
  while (c < '0' || c > '9') {
    if (c == '-') flag = -flag;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    ans = ans * 10 + c - '0';
    c = getchar();
  }
  return ans * flag;
}
const long long INF = 1e16;
const int N = 85;
const int MOD = 998244353;
int a[N], b[N], dp[N][N * N][N], ans[N * N];
int n, tot;
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) {
    a[i] = read();
    if (a[i] == 1) b[++tot] = i;
  }
  memset(dp, 0xcf, sizeof(dp));
  dp[0][0][0] = 0;
  for (int i = 0; i < tot; ++i)
    for (int j = 0; j <= i * (n - i); ++j)
      for (int k = i; k <= n; ++k)
        if (dp[i][j][k] >= 0) {
          for (int l = k + 1; l <= n; ++l)
            dp[i + 1][j + abs(l - b[i + 1])][l] =
                max(dp[i + 1][j + abs(l - b[i + 1])][l],
                    dp[i][j][k] + (k - i) * (l - k - 1));
        }
  for (int i = 0; i <= n * (n - 1) / 2; ++i) {
    if (i > 0) ans[i] = ans[i - 1];
    for (int j = tot; j <= n; ++j)
      ans[i] = max(ans[i], dp[tot][i][j] + (n - j) * (j - tot));
    printf("%d ", ans[i]);
  }
  return 0;
}
