#include <bits/stdc++.h>
using namespace std;
template <typename T>
string to_string(const pair<T, T>& pr) {
  return "(" + to_string(pr.first) + "," + to_string(pr.second) + ")";
}
template <typename T>
string to_string(const vector<T>& vc, int w) {
  if (vc.empty()) return "";
  if (w + 1 == vc.size()) return to_string(vc[w]);
  return to_string(vc[w]) + "," + to_string(vc, w + 1);
}
template <typename T>
string to_string(const vector<T>& vc) {
  return "{" + to_string(vc, 0) + "}";
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
class DebugStream {
} LOG;
template <typename T>
DebugStream& operator<<(DebugStream& s, const T&) {
  return s;
}
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
const int maxN = 82, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;
int dp[maxN][maxN][maxN * maxN];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n;
  k = n * (n - 1) / 2;
  vector<int> arr({0});
  for (int i = 0, inp; i < n; i++) {
    cin >> inp;
    if (!inp)
      arr.back()++;
    else
      arr.push_back(0);
  }
  int s = accumulate(arr.begin(), arr.end(), 0);
  n = arr.size();
  vector<int> prf(n);
  prf[0] = arr[0];
  for (int i = 1; i < n; i++) prf[i] = prf[i - 1] + arr[i];
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= s; j++)
      for (int a = 0; a <= k; a++) dp[i][j][a] = -MOD;
  dp[0][0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= s; j++) {
      for (int a = 0; a <= k; a++) {
        if (dp[i][j][a] == -MOD) continue;
        for (int h = 0; h <= s; h++) {
          int nwJ = j + h;
          int cnd = abs(j + h - prf[i]);
          int nwA = a + cnd;
          if (nwJ > s || nwA > k) continue;
          dp[i + 1][nwJ][nwA] = max(dp[i + 1][nwJ][nwA], dp[i][j][a] + j * h);
        }
      }
    }
  }
  for (int i = 0, bst = 0; i <= k; i++) {
    bst = max(bst, dp[n][s][i]);
    cout << bst << ' ';
  }
  cout << '\n';
}
