#include <bits/stdc++.h>
using namespace std;
inline void prep() {
  cin.tie(0);
  cin.sync_with_stdio(0);
};
const int biggg = 1000000001;
const long long bigggest = 1000000000000000000LL;
const double eps = .0000000001;
const double pi = acos(-1.);
int memo[80][81][3161];
int poss[80];
int n;
int arr[80];
int lim;
int ones = 0;
int zeros = 0;
int func(int ind, int cur1, int move) {
  if (ind >= n && move == 0 && cur1 == ones) {
    return 0;
  }
  if (ind >= n) return -biggg;
  if (memo[ind][cur1][move] != -1) return memo[ind][cur1][move];
  int biggest = 0;
  for (int i = ind; i < n && cur1 != ones; i++) {
    int dist = abs(i - poss[cur1]);
    if (move - dist < 0) continue;
    int res =
        (i - ind) * (zeros - i + cur1) + func(i + 1, cur1 + 1, move - dist);
    biggest = max(biggest, res);
  }
  memo[ind][cur1][move] = biggest;
  return biggest;
}
int main() {
  prep();
  cin >> n;
  memset(memo, -1, sizeof(int) * 80 * 81 * ((80 * 79) / 2 + 1));
  lim = n * (n - 1) / 2;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    if (arr[i]) {
      poss[ones] = i;
      ones++;
    } else {
      zeros++;
    }
  }
  for (int i = 0; i <= n * (n - 1) / 2; i++) {
    printf("%d ", func(0, 0, i));
  }
  cerr << "80\n";
  for (int i = 0; i < 80; i++) {
    cerr << rand() % 2 << " ";
  }
  return 0;
}
