Problem: A lighthouse keeper Peter commands an army of n battle lemmings. He ordered his army to stand in a line and numbered the lemmings from 1 to n from left to right. Some of the lemmings hold shields. Each lemming cannot hold more than one shield.

The more protected Peter's army is, the better. To calculate the protection of the army, he finds the number of protected pairs of lemmings, that is such pairs that both lemmings in the pair don't hold a shield, but there is a lemming with a shield between them.

Now it's time to prepare for defence and increase the protection of the army. To do this, Peter can give orders. He chooses a lemming with a shield and gives him one of the two orders: 

  * give the shield to the left neighbor if it exists and doesn't have a shield; 
  * give the shield to the right neighbor if it exists and doesn't have a shield. 



In one second Peter can give exactly one order.

It's not clear how much time Peter has before the defence. So he decided to determine the maximal value of army protection for each k from 0 to \frac{n(n-1)}2, if he gives no more that k orders. Help Peter to calculate it!

Input

First line contains a single integer n (1 ≤ n ≤ 80), the number of lemmings in Peter's army.

Second line contains n integers a_i (0 ≤ a_i ≤ 1). If a_i = 1, then the i-th lemming has a shield, otherwise a_i = 0.

Output

Print \frac{n(n-1)}2 + 1 numbers, the greatest possible protection after no more than 0, 1, ..., \frac{n(n-1)}2 orders.

Examples

Input


5
1 0 0 0 1


Output


0 2 3 3 3 3 3 3 3 3 3 


Input


12
0 0 0 0 1 1 1 1 0 1 1 0


Output


9 12 13 14 14 14 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 

Note

Consider the first example.

The protection is initially equal to zero, because for each pair of lemmings without shields there is no lemmings with shield.

In one second Peter can order the first lemming give his shield to the right neighbor. In this case, the protection is two, as there are two protected pairs of lemmings, (1, 3) and (1, 4).

In two seconds Peter can act in the following way. First, he orders the fifth lemming to give a shield to the left neighbor. Then, he orders the first lemming to give a shield to the right neighbor. In this case Peter has three protected pairs of lemmings — (1, 3), (1, 5) and (3, 5).

You can make sure that it's impossible to give orders in such a way that the protection becomes greater than three.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
clock_t time_p = clock();
void time_taken() {
  time_p = clock() - time_p;
  cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}
const long long mod = 1e9 + 7;
const long long INF = 1e18;
struct line {
  int a, b;
  double xleft;
  bool type;
  line(long long _a, long long _b) {
    a = _a;
    b = _b;
    type = 0;
  }
  bool operator<(const line &other) const {
    if (other.type) {
      return xleft < other.xleft;
    }
    return a > other.a;
  }
};
double meet(line x, line y) { return 1.0 * (y.b - x.b) / (x.a - y.a); }
struct cht {
  set<line> hull;
  cht() { hull.clear(); }
  bool hasleft(set<line>::iterator node) { return node != hull.begin(); }
  bool hasright(set<line>::iterator node) { return node != prev(hull.end()); }
  void updateborder(set<line>::iterator node) {
    if (hasright(node)) {
      line temp = *next(node);
      hull.erase(temp);
      temp.xleft = meet(*node, temp);
      hull.insert(temp);
    }
    if (hasleft(node)) {
      line temp = *node;
      temp.xleft = meet(*prev(node), temp);
      hull.erase(node);
      hull.insert(temp);
    } else {
      line temp = *node;
      hull.erase(node);
      temp.xleft = -1e18;
      hull.insert(temp);
    }
  }
  bool useless(line left, line middle, line right) {
    double x = meet(left, right);
    double y = x * middle.a + middle.b;
    double ly = left.a * x + left.b;
    return y > ly;
  }
  bool useless(set<line>::iterator node) {
    if (hasleft(node) && hasright(node)) {
      return useless(*prev(node), *node, *next(node));
    }
    return 0;
  }
  void addline(int a, int b) {
    line temp = line(a, b);
    auto it = hull.lower_bound(temp);
    if (it != hull.end() && it->a == a) {
      if (it->b > b) {
        hull.erase(it);
      } else {
        return;
      }
    }
    hull.insert(temp);
    it = hull.find(temp);
    if (useless(it)) {
      hull.erase(it);
      return;
    }
    while (hasleft(it) && useless(prev(it))) {
      hull.erase(prev(it));
    }
    while (hasright(it) && useless(next(it))) {
      hull.erase(next(it));
    }
    updateborder(it);
  }
  int getbest(int x) {
    if (hull.empty()) {
      return mod;
    }
    line query(0, 0);
    query.xleft = x;
    query.type = 1;
    auto it = hull.lower_bound(query);
    it = prev(it);
    return it->a * x + it->b;
  }
};
const int nax = 85;
int dp[2][nax][nax * nax];
int main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> a(n);
  int ones = 0;
  for (int i = 0; i < n; i++) cin >> a[i], ones += a[i];
  if (ones == 0) {
    for (int i = 0; i < n * (n - 1) / 2 + 1; i++) {
      cout << 0 << ' ';
    }
    cout << '\n';
    return 0;
  }
  vector<int> b;
  for (int i = 0; i < n; i++) {
    if (a[i] == 1) b.push_back(i);
  }
  int K = n * (n - 1) / 2 + 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < K; j++) {
      dp[0][i][j] = mod;
      int req = abs(b[0] - i);
      if (j >= req) dp[0][i][j] = i * (i - 1) / 2;
    }
  }
  int m = (int)(b).size();
  for (int i = 1; i <= m - 1; i++) {
    vector<cht> ds(K + 1);
    for (int k = 0; k < K; k++) {
      int j = i - 1;
      if (dp[0][i - 1][k] < mod)
        ds[k].addline(-2 * j, j * j + 3 * j + 2 * dp[0][j][k]);
    }
    for (int j = i; j <= n - (m - i); j++) {
      for (int k = 0; k < K; k++) {
        dp[1][j][k] = mod;
        if (k < abs(b[i] - j)) continue;
        int kk = k - abs(b[i] - j);
        int foo = ds[kk].getbest(j);
        if (foo <= mod)
          dp[1][j][k] = min<int>(dp[1][j][k], (foo + j * j - 3 * j + 2) / 2);
      }
      for (int k = 0; k < K; k++) {
        if (dp[0][j][k] < mod)
          ds[k].addline(-2 * j, j * j + 3 * j + 2 * dp[0][j][k]);
        dp[0][j][k] = dp[1][j][k];
      }
    }
    for (int k = 0; k < K; k++) {
      dp[0][n - (m - i) + 1][k] = mod;
    }
  }
  int mn = mod;
  for (int k = 0; k < K; k++) {
    for (int j = 0; j < n; j++) {
      mn = min(mn, dp[0][j][k] + (n - j - 1) * (n - j - 2) / 2);
    }
    int foo = (n - ones) * (n - ones - 1) / 2;
    cout << foo - mn << ' ';
  }
  cout << '\n';
  time_taken();
  return 0;
}