#include <bits/stdc++.h>
const int MAX_N = 105;
const int INF = 1e9;
int a[MAX_N];
int dp[MAX_N][MAX_N][MAX_N * (MAX_N + 1) / 2];
int main() {
  int n;
  std::cin >> n;
  for (int i = 0; i < n; i++) std::cin >> a[i];
  a[n] = 1;
  std::vector<int> f;
  for (int i = 0; i <= n; i++) {
    int aux = i;
    while (a[i] == 0) i++;
    f.push_back(i - aux);
  }
  std::vector<int> sumPart = f;
  std::partial_sum(sumPart.begin(), sumPart.end(), sumPart.begin());
  for (int i = 0; i < MAX_N; i++)
    for (int j = 0; j < MAX_N; j++)
      for (int t = 0; t < MAX_N * (MAX_N + 1) / 2; t++) dp[i][j][t] = INF;
  dp[0][0][0] = 0;
  int nr1 = f.size() - 1;
  int nr0 = sumPart.back();
  for (int i = 0; i <= nr1; i++)
    for (int j = 0; j <= nr0; j++)
      for (int t = 0; t <= n * (n - 1) / 2; t++)
        if (dp[i][j][t] != INF)
          for (int k = j; k <= nr0; k++)
            dp[i + 1][k][t + std::abs(k - sumPart[i])] =
                std::min(dp[i + 1][k][t + std::abs(k - sumPart[i])],
                         dp[i][j][t] + (k - j) * (k - j));
  int min = INF;
  for (int t = 0; t <= n * (n - 1) / 2; t++) {
    min = std::min(min, dp[nr1 + 1][nr0][t]);
    std::cout << (nr0 * nr0 - min) / 2 << " ";
  }
  return 0;
}
