#include <bits/stdc++.h>
const int M = 83;
int n, num = 1;
int a[M], cnt[M], sum[M];
int dp[M][M][M * M / 2];
template <typename T>
inline void read(T &x) {
  x = 0;
  char ch = getchar();
  int f = 1;
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') f = -1;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
  x *= f;
}
int main() {
  read(n);
  for (int i = 1; i <= n; i++) read(a[i]);
  for (int i = 1; i <= n; i++)
    if (!a[i])
      cnt[num]++;
    else
      num++;
  for (int i = 1; i <= num; i++) sum[i] = sum[i - 1] + cnt[i];
  memset(dp, 0x3f, sizeof(dp));
  dp[0][0][0] = 0;
  for (int i = 0; i < num; i++)
    for (int j = 0; j <= sum[num]; j++)
      for (int k = 0; k <= n * (n - 1) / 2; k++)
        if (dp[i][j][k] < 1e9)
          for (int x = j; x <= sum[num]; x++)
            if (k + abs(x - sum[i + 1]) <= n * (n - 1) / 2)
              dp[i + 1][x][k + abs(x - sum[i + 1])] =
                  std::min(dp[i + 1][x][k + abs(x - sum[i + 1])],
                           dp[i][j][k] + (x - j) * (x - j));
  int x = 0x3f3f3f3f;
  for (int i = 0; i <= n * (n - 1) / 2; i++)
    x = std::min(x, dp[num][sum[num]][i]),
    printf("%d ", (sum[num] * sum[num] - x) / 2);
  return 0;
}
