#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void prn(Arg1&& arg1) {
  cout << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void prn(Arg1&& arg1, Args&&... args) {
  cout << arg1 << " ";
  prn(args...);
}
template <typename Arg1>
void prs(Arg1&& arg1) {
  cout << arg1 << " ";
}
template <typename Arg1, typename... Args>
void prs(Arg1&& arg1, Args&&... args) {
  cout << arg1 << " ";
  prs(args...);
}
template <typename Arg1>
void read(Arg1&& arg1) {
  cin >> arg1;
}
template <typename Arg1, typename... Args>
void read(Arg1&& arg1, Args&&... args) {
  cin >> arg1;
  read(args...);
}
const int N = 85, inf = 1e9;
int arr[N], dp[N][N][N * N];
vector<int> pos;
int n, num0;
int maxpos(int pidx, int idx, int lft) {
  if (idx >= pos.size()) {
    return 0;
  }
  if (pidx + 1 > n) {
    return -inf;
  }
  int& ans = dp[pidx][idx][lft];
  if (ans != -1) return ans;
  ans = -inf;
  int l = max(pidx + 1, pos[idx] - lft), r = min(n, pos[idx] + lft);
  for (int place = l; place <= r; ++place) {
    ans = max(ans, (num0 - place + 1 + idx) * (place - pidx - 1) +
                       maxpos(place, idx + 1, lft - abs(pos[idx] - place)));
  }
  return ans;
}
void solve() {
  read(n);
  for (int i = 1; i <= n; ++i) {
    read(arr[i]);
    if (arr[i]) {
      pos.push_back(i);
    } else {
      ++num0;
    }
  }
  (pos, num0);
  memset(dp, -1, sizeof dp);
  int tot = (n * n - n) / 2;
  int ans = -1;
  int k = (n + 1) / 2;
  int tot1 = (k * k + k) / 2;
  for (int i = 0; i <= tot; ++i) {
    if (i <= tot1) ans = maxpos(0, 0, i);
    prs(ans);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  for (int tc = 1; tc <= t; ++tc) {
    solve();
  }
  return 0;
}
