#include <bits/stdc++.h>
using namespace std;
using namespace std;
const int maxn = 80 + 5;
const int maxm = 50 + 10;
const long long inf = 1e9;
const long long mod = 998244353;
int n, a[maxn], f[maxn], m;
int sum[maxn];
int dp[2][maxn][maxn * maxn / 2];
inline void clear(int t) {
  for (auto i = (0); i <= (sum[m]); ++i)
    for (auto j = (0); j <= (n * (n - 1) / 2); ++j) dp[t][i][j] = inf;
}
inline void init() {
  for (int i = 1; i <= n;) {
    int j = i + 1;
    while (a[j] == 0) ++j;
    f[++m] = j - i - 1;
    sum[m] = sum[m - 1] + f[m];
    i = j;
  }
}
inline void solve() {
  init();
  int t;
  clear(t = 0);
  dp[t][0][0] = 0;
  int full = (n - 1) * (n - 2) / 2;
  for (auto i = (1); i <= (m); ++i) {
    clear(t ^ 1);
    for (auto j = (0); j <= (sum[m]); ++j) {
      for (auto k = (0); k <= (full); ++k) {
        for (auto x = (0); x <= (sum[m] - j); ++x) {
          if (dp[t][j][k] >= inf) continue;
          if (abs(x + j - sum[i]) + k > full) continue;
          int& ans = dp[t ^ 1][j + x][abs(x + j - sum[i]) + k];
          ans = min(ans, dp[t][j][k] + x * x);
        }
      }
    }
    t ^= 1;
  }
  int ans = dp[t][sum[m]][0];
  printf("%d", (sum[m] * sum[m] - ans) / 2);
  for (auto i = (1); i <= (full); ++i) {
    ans = min(ans, dp[t][sum[m]][i]);
    printf(" %d", (sum[m] * sum[m] - ans) / 2);
  }
  puts("");
}
int main(void) {
  scanf("%d", &(n));
  ++n;
  for (auto i = (2); i <= (n); ++i) scanf("%d", &(a[i]));
  a[1] = 1, a[n + 1] = 1;
  solve();
  return 0;
}
