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;
const int MN = 82;
int N, K, i, j, k, x, y, tmp[MN][MN * MN];
deque<pair<int, int> > dp[MN][MN * MN];
vector<int> pos;
inline int eval(pair<int, int> ln, int x) {
  return (ln.first - x - 1) * (ln.first - x - 2) / 2 + ln.second;
}
inline double eval(pair<int, int> ln, double x) {
  return (ln.first - x - 1) * (ln.first - x - 2) / 2 + ln.second;
}
inline double isect(pair<int, int> ln, pair<int, int> ln2) {
  double lo = 0, hi = min(ln.first, ln2.first);
  while (lo + 0.001 < hi) {
    double mid = (lo + hi) / 2;
    if (eval(ln, mid) <= eval(ln2, mid))
      hi = mid;
    else
      lo = mid + 0.001;
  }
  return lo;
}
int main() {
  scanf("%d", &N);
  for (i = 1; i <= N; i++) {
    scanf("%d", &x);
    if (x) {
      K++;
      pos.push_back(i);
    }
  }
  dp[K][0].push_back({N + 1, 0});
  for (i = N; i >= 1; i--) {
    memset(tmp, -1, sizeof(tmp));
    for (j = 0; j < K; j++) {
      for (k = abs(pos[j] - i); k <= N * (N - 1) / 2; k++) {
        while (dp[j + 1][k - abs(pos[j] - i)].size() >= 2) {
          pair<int, int> fs = dp[j + 1][k - abs(pos[j] - i)].front();
          dp[j + 1][k - abs(pos[j] - i)].pop_front();
          if (eval(fs, i) >= eval(dp[j + 1][k - abs(pos[j] - i)].front(), i))
            continue;
          else {
            dp[j + 1][k - abs(pos[j] - i)].push_front(fs);
            break;
          }
        }
        if (dp[j + 1][k - abs(pos[j] - i)].size()) {
          tmp[j][k] = eval(dp[j + 1][k - abs(pos[j] - i)].front(), i);
        }
      }
    }
    for (j = 0; j < K; j++) {
      for (k = 0; k <= N * (N - 1) / 2; k++) {
        if (tmp[j][k] != -1) {
          while (dp[j][k].size() >= 2) {
            pair<int, int> lst = dp[j][k].back();
            dp[j][k].pop_back();
            if (ceil(isect(dp[j][k].back(), lst)) <=
                floor(isect(lst, make_pair(i, tmp[j][k]))))
              continue;
            else {
              dp[j][k].push_back(lst);
              break;
            }
          }
          dp[j][k].push_back({i, tmp[j][k]});
        }
        while (dp[j][k].size() >= 2) {
          pair<int, int> fs = dp[j][k].front();
          dp[j][k].pop_front();
          if (eval(fs, i) >= eval(dp[j][k].front(), i))
            continue;
          else {
            dp[j][k].push_front(fs);
            break;
          }
        }
      }
    }
  }
  int ans = 0;
  for (k = 0; k <= N * (N - 1) / 2; k++) {
    while (dp[0][k].size() >= 2) {
      pair<int, int> fs = dp[0][k].front();
      dp[0][k].pop_front();
      if (eval(fs, 0) >= eval(dp[0][k].front(), 0))
        continue;
      else {
        dp[0][k].push_front(fs);
        break;
      }
    }
    if (dp[0][k].size())
      ans = max(ans, (N - K) * (N - K - 1) / 2 - eval(dp[0][k].front(), 0));
    printf("%d ", ans);
  }
  printf("\n");
  return 0;
}