#include <bits/stdc++.h>
using namespace std;
namespace STDquantum {
template <typename T>
inline void read(T &x) {
  char ch;
  int f = 1;
  while (ch = getchar(), !isdigit(ch))
    if (ch == '-') f = -1;
  x = (ch ^ 48);
  while (ch = getchar(), isdigit(ch)) x = x * 10 + (ch ^ 48);
  x *= f;
}
template <typename T>
inline void write(T x) {
  static int stk[100], top = 0;
  if (x == 0) return (void)putchar('0');
  if (x < 0) x = -x, putchar('-');
  while (x) stk[++top] = x % 10, x /= 10;
  while (top) putchar(stk[top--] + '0');
}
const int N = 80 + 6, inf = 0x3f3f3f3f;
inline void min(int &x, const int &y) { x = x < y ? x : y; }
int n, k, s[N], z[N], f[N][N][N * N];
inline void main() {
  read(n);
  int a, cnt = 0;
  for (int i = 1; i <= n; ++i) {
    read(a);
    if (a) {
      s[++k] = cnt, cnt = 0;
    } else {
      ++cnt;
    }
  }
  s[++k] = cnt;
  for (int i = 1; i <= k; ++i) z[i] = z[i - 1] + s[i];
  memset(f, 0x3f, sizeof(f)), f[0][0][0] = 0;
  int top = n * (n - 1) / 2, maxx = z[k];
  for (int i = 0; i < k; ++i) {
    for (int sum = 0; sum <= maxx; ++sum) {
      for (int op = 0; op <= top; ++op) {
        if (f[i][sum][op] == inf) continue;
        for (int q = sum, tmp, h; q <= maxx; ++q) {
          if ((tmp = op + abs(q - z[i + 1])) > top) continue;
          h = q - sum;
          min(f[i + 1][q][tmp], f[i][sum][op] + h * h);
        }
      }
    }
  }
  int minn = inf;
  for (int i = 0; i <= top; ++i) {
    min(minn, f[k][maxx][i]);
    write((maxx * maxx - minn) / 2), putchar(' ');
  }
}
}  // namespace STDquantum
int main() {
  STDquantum::main();
  return 0;
}
