#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 82;
const int mod = 998244353;
const int base = 131;
const double eps = 1e-7;
namespace IO {
long long read() {
  long long a = 1, b = 0;
  char c = getchar();
  while (c > '9' || c < '0') {
    if (c == '-') a = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    b = (b << 3) + (b << 1) + c - '0';
    c = getchar();
  }
  return a * b;
}
void print(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) print(x / 10);
  putchar(x % 10 + '0');
}
}  // namespace IO
using namespace IO;
inline void DEBUG(long long x) { cout << "asdasd" << x << endl; }
int n;
int b[maxn], m = 1, c[maxn];
int dp[maxn][maxn][maxn * maxn];
int main() {
  n = read();
  int tmp;
  bool flag = 0;
  for (int i = 1; i <= n; ++i) {
    tmp = read();
    if (tmp == 1)
      m++;
    else
      b[m]++;
  }
  for (int i = 1; i <= m; ++i) c[i] = c[i - 1] + b[i];
  memset(dp, 0x3f, sizeof(dp));
  dp[0][0][0] = 0;
  int num = n * (n - 1) / 2;
  for (int i = 0; i <= m - 1; ++i) {
    for (int j = 0; j <= c[m]; ++j) {
      for (int opt = 0; opt <= num; ++opt) {
        if (dp[i][j][opt] == 0x3f3f3f3f) continue;
        for (int l = j; l <= c[m]; ++l) {
          if (opt + abs(l - c[i + 1]) > num) continue;
          int &tmp = dp[i + 1][l][opt + abs(l - c[i + 1])];
          tmp = min(tmp, dp[i][j][opt] + (l - j) * (l - j));
        }
      }
    }
  }
  int mn = 0x3f3f3f3f;
  for (int i = 0; i <= num; ++i) {
    mn = min(mn, dp[m][c[m]][i]);
    print((c[m] * c[m] - mn) >> 1);
    putchar('\n');
  }
  return 0;
}
