#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define F first
#define S second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const int inf = (int)1e8;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

const int N = 81;

vector < int > pos;
int n, a[N], dp[N][N][N][N];

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

	//cin.tie(NULL);
	//cout.tie(NULL);
	//ios_base::sync_with_stdio(false);

	//cout << setprecision(10) << fixed;

	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if (a[i])
			pos.pb(i);
	}

	for (int i = 0; i < N; i++)
		for (int j = 0; j < N; j++)
			for (int k = 0; k < N; k++)
				for (int x = 0; x < N; x++)
					dp[i][j][k][x] = inf;

	dp[0][0][0][0] = 0;

	int tot = sz(pos);

	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= min(i, tot); j++) {
			for (int k = 0; k <= i - j; k++) {
				for (int x = 0; x <= n; x++) {
					dp[i + 1][j][k + 1][x] = min(dp[i + 1][j][k + 1][x], dp[i][j][k][x] + k);
					if (x + abs(pos[j] - (i + 1)) <= n)
						dp[i + 1][j + 1][0][x + abs(pos[j] - (i + 1))] = min(dp[i + 1][j + 1][0][x + abs(pos[j] - (i + 1))], dp[i][j][k][x]);
				}
			}
		}
	}

	int add = n * (n - 1) / 2 - tot * (n - tot) - tot * (tot - 1) / 2;

	int ans = inf;

	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n - tot; j++)
			ans = min(ans, dp[n][tot][j][i]);
		cout << add - ans << " ";
	}
	for (int i = n + 1; i <= n * (n - 1) / 2; i++)
		cout << add - ans << " ";

	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}


#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define F first
#define S second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const int inf = (int)1e8;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

const int N = 81;
const int M = 801;

vector < int > pos;
int n, a[N], prv[N][N][N * N], nxt[N][N][N * N];

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

	//cin.tie(NULL);
	//cout.tie(NULL);
	//ios_base::sync_with_stdio(false);

	//cout << setprecision(10) << fixed;

	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if (a[i])
			pos.pb(i);
	}

	for (int j = 0; j < N; j++)
		for (int k = 0; k < N; k++)
			for (int x = 0; x < M; x++)
				prv[j][k][x] = nxt[j][k][x] = inf;

	prv[0][0][0] = 0;

	int tot = sz(pos);

	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= min(i, tot); j++) {
			for (int k = 0; k <= min(i - j, n - tot); k++) {
				for (int x = 0; x <= n; x++) {
					nxt[j][k + 1][x] = min(nxt[j][k + 1][x], prv[j][k][x] + k);
					if (x + abs(pos[j] - (i + 1)) <= n)
						nxt[j + 1][0][x + abs(pos[j] - (i + 1))] = min(nxt[j + 1][0][x + abs(pos[j] - (i + 1))], prv[j][k][x]);
				}
			}
		}
		for (int j = 0; j < N; j++) {
			for (int k = 0; k < N; k++) {
				for (int x = 0; x < M; x++) {
					swap(prv[j][k][x], nxt[j][k][x]);
					nxt[j][k][x] = inf;
				}
			}
		}
	}

	int add = n * (n - 1) / 2 - tot * (n - tot) - tot * (tot - 1) / 2;

	int ans = inf;

	for (int i = 0; i <= min(M - 1, n * (n - 1) / 2); i++) {
		for (int j = 0; j <= n - tot; j++)
			ans = min(ans, prv[tot][j][i]);
		cout << add - ans << " ";
	}
	for (int i = M; i <= n * (n - 1) / 2; i++)
		cout << add - ans << " ";

	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}


#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define F first
#define S second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const int inf = (int)1e8;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

const int N = 81;

vector < int > pos[2];
int n, a[N], cnt0[N][N], cnt1[N][N], dp[N][N][N][2 * N];

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

	//cin.tie(NULL);
	//cout.tie(NULL);
	//ios_base::sync_with_stdio(false);

	//cout << setprecision(10) << fixed;

	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		pos[a[i]].pb(i);
	}

	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < sz(pos[0]); j++)
			cnt0[j + 1][i] = cnt0[j][i] + (pos[0][j] > i);
		for (int j = 0; j < sz(pos[1]); j++)
			cnt1[j + 1][i] = cnt1[j][i] + (pos[1][j] > i);
	}

	for (int i = 0; i < N; i++)
		for (int j = 0; j < N; j++)
			for (int k = 0; k < N; k++)
				for (int x = 0; x < N + N; x++)
					dp[i][j][k][x] = inf;

	dp[0][0][0][0] = 0;

	int tot = sz(pos[1]);

	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= min(i, tot); j++) {
			int zer = i - j;
			for (int k = 0; k <= min(i - j, n - tot); k++) {
				for (int x = 0; x <= n + n; x++) {
					if (zer < sz(pos[0])) {
					    int newpos = pos[0][zer] + cnt1[j][pos[0][zer]];
					    if (i + 1 <= newpos && x + newpos - (i + 1) <= n + n)
							dp[i + 1][j][k + 1][x + newpos - (i + 1)] = min(dp[i + 1][j][k + 1][x + newpos - (i + 1)], dp[i][j][k][x] + k);
					}
					if (j < sz(pos[1])) {
						int newpos = pos[1][j] + cnt0[zer][pos[1][j]];
						if (i + 1 <= newpos && x + newpos - (i + 1) <= n + n)
							dp[i + 1][j + 1][0][x + newpos - (i + 1)] = min(dp[i + 1][j + 1][0][x + newpos - (i + 1)], dp[i][j][k][x]);
					}

				}
			}
		}
	}

	int add = n * (n - 1) / 2 - tot * (n - tot) - tot * (tot - 1) / 2;

	int ans = inf;

	for (int i = 0; i <= min(n + n, n * (n - 1) / 2); i++) {
		for (int j = 0; j <= n - tot; j++)
			ans = min(ans, dp[n][tot][j][i]);
		cout << add - ans << " ";
	}
	for (int i = n + n + 1; i <= n * (n - 1) / 2; i++)
		cout << add - ans << " ";

	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}


#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define F first
#define S second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const int inf = (int)1e8;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

const int N = 81;
const int M = 801;

vector < int > pos;
int n, a[N], prv[N][N][N * N], nxt[N][N][N * N];

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

	//cin.tie(NULL);
	//cout.tie(NULL);
	//ios_base::sync_with_stdio(false);

	//cout << setprecision(10) << fixed;

	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if (a[i])
			pos.pb(i);
	}

	for (int j = 0; j < N; j++)
		for (int k = 0; k < N; k++)
			for (int x = 0; x < M; x++)
				prv[j][k][x] = nxt[j][k][x] = inf;

	prv[0][0][0] = 0;

	int tot = sz(pos);

	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= min(i, tot); j++) {
			for (int k = 0; k <= min(i - j, n - tot); k++) {
				for (int x = 0; x < M; x++) {
					nxt[j][k + 1][x] = min(nxt[j][k + 1][x], prv[j][k][x] + k);
					if (x + abs(pos[j] - (i + 1)) < M)
						nxt[j + 1][0][x + abs(pos[j] - (i + 1))] = min(nxt[j + 1][0][x + abs(pos[j] - (i + 1))], prv[j][k][x]);
				}
			}
		}
		for (int j = 0; j < N; j++) {
			for (int k = 0; k < N; k++) {
				for (int x = 0; x < M; x++) {
					swap(prv[j][k][x], nxt[j][k][x]);
					nxt[j][k][x] = inf;
				}
			}
		}
	}

	int add = n * (n - 1) / 2 - tot * (n - tot) - tot * (tot - 1) / 2;

	int ans = inf;

	for (int i = 0; i <= min(M - 1, n * (n - 1) / 2); i++) {
		for (int j = 0; j <= n - tot; j++)
			ans = min(ans, prv[tot][j][i]);
		cout << add - ans << " ";
	}
	for (int i = M; i <= n * (n - 1) / 2; i++)
		cout << add - ans << " ";

	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}


#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define F first
#define S second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const int inf = (int)1e8;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

const int N = 81;

vector < int > pos[2];
int n, a[N], cnt0[N][N], cnt1[N][N], dp[N][N][N][2 * N];

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

	//cin.tie(NULL);
	//cout.tie(NULL);
	//ios_base::sync_with_stdio(false);

	//cout << setprecision(10) << fixed;

	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		pos[a[i]].pb(i);
	}

	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < sz(pos[0]); j++)
			cnt0[j + 1][i] = cnt0[j][i] + (pos[0][j] > i);
		for (int j = 0; j < sz(pos[1]); j++)
			cnt1[j + 1][i] = cnt1[j][i] + (pos[1][j] > i);
	}

	for (int i = 0; i < N; i++)
		for (int j = 0; j < N; j++)
			for (int k = 0; k < N; k++)
				for (int x = 0; x < N; x++)
					dp[i][j][k][x] = inf;

	dp[0][0][0][0] = 0;

	int tot = sz(pos[1]);

	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= min(i, tot); j++) {
			int zer = i - j;
			for (int k = 0; k <= min(i - j, n - tot); k++) {
				for (int x = 0; x <= n; x++) {
					if (zer < sz(pos[0])) {
					    int newpos = pos[0][zer] + cnt1[j][pos[0][zer]];
					    if (i + 1 <= newpos && x + newpos - (i + 1) <= n)
							dp[i + 1][j][k + 1][x + newpos - (i + 1)] = min(dp[i + 1][j][k + 1][x + newpos - (i + 1)], dp[i][j][k][x] + k);
					}
					if (j < sz(pos[1])) {
						int newpos = pos[1][j] + cnt0[zer][pos[1][j]];
						if (i + 1 <= newpos && x + newpos - (i + 1) <= n)
							dp[i + 1][j + 1][0][x + newpos - (i + 1)] = min(dp[i + 1][j + 1][0][x + newpos - (i + 1)], dp[i][j][k][x]);
					}

				}
			}
		}
	}

	int add = n * (n - 1) / 2 - tot * (n - tot) - tot * (tot - 1) / 2;

	int ans = inf;

	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n - tot; j++)
			ans = min(ans, dp[n][tot][j][i]);
		cout << add - ans << " ";
	}
	for (int i = n + 1; i <= n * (n - 1) / 2; i++)
		cout << add - ans << " ";

	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}


#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define F first
#define S second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const int inf = (int)1e8;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

const int N = 81;

vector < int > pos[2];
int n, a[N], cnt0[N][N], cnt1[N][N], dp[N][N][N][2 * N];

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

	//cin.tie(NULL);
	//cout.tie(NULL);
	//ios_base::sync_with_stdio(false);

	//cout << setprecision(10) << fixed;

	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		pos[a[i]].pb(i);
	}

	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < sz(pos[0]); j++)
			cnt0[j + 1][i] = cnt0[j][i] + (pos[0][j] > i);
		for (int j = 0; j < sz(pos[1]); j++)
			cnt1[j + 1][i] = cnt1[j][i] + (pos[1][j] > i);
	}

	for (int i = 0; i < N; i++)
		for (int j = 0; j < N; j++)
			for (int k = 0; k < N; k++)
				for (int x = 0; x < N; x++)
					dp[i][j][k][x] = inf;

	dp[0][0][0][0] = 0;

	int tot = sz(pos[1]);

	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= min(i, tot); j++) {
			int zer = i - j;
			for (int k = 0; k <= min(i - j, n - tot); k++) {
				for (int x = 0; x <= n + n; x++) {
					if (zer < sz(pos[0])) {
					    int newpos = pos[0][zer] + cnt1[j][pos[0][zer]];
					    if (i + 1 <= newpos && x + newpos - (i + 1) <= n + n)
							dp[i + 1][j][k + 1][x + newpos - (i + 1)] = min(dp[i + 1][j][k + 1][x + newpos - (i + 1)], dp[i][j][k][x] + k);
					}
					if (j < sz(pos[1])) {
						int newpos = pos[1][j] + cnt0[zer][pos[1][j]];
						if (i + 1 <= newpos && x + newpos - (i + 1) <= n + n)
							dp[i + 1][j + 1][0][x + newpos - (i + 1)] = min(dp[i + 1][j + 1][0][x + newpos - (i + 1)], dp[i][j][k][x]);
					}

				}
			}
		}
	}

	int add = n * (n - 1) / 2 - tot * (n - tot) - tot * (tot - 1) / 2;

	int ans = inf;

	for (int i = 0; i <= n + n; i++) {
		for (int j = 0; j <= n - tot; j++)
			ans = min(ans, dp[n][tot][j][i]);
		cout << add - ans << " ";
	}
	for (int i = n + n + 1; i <= n * (n - 1) / 2; i++)
		cout << add - ans << " ";

	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}


#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define F first
#define S second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const int inf = (int)1e8;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

const int N = 81;

vector < int > pos;
int n, a[N], dp[N][N][N][2 * N];

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

	//cin.tie(NULL);
	//cout.tie(NULL);
	//ios_base::sync_with_stdio(false);

	//cout << setprecision(10) << fixed;

	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if (a[i])
			pos.pb(i);
	}

	for (int i = 0; i < N; i++)
		for (int j = 0; j < N; j++)
			for (int k = 0; k < N; k++)
				for (int x = 0; x < N; x++)
					dp[i][j][k][x] = inf;

	dp[0][0][0][0] = 0;

	int tot = sz(pos);

	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= min(i, tot); j++) {
			for (int k = 0; k <= min(i - j, n - tot); k++) {
				for (int x = 0; x <= n; x++) {
					dp[i + 1][j][k + 1][x] = min(dp[i + 1][j][k + 1][x], dp[i][j][k][x] + k);
					if (j < tot && x + abs(pos[j] - (i + 1)) <= n)
						dp[i + 1][j + 1][0][x + abs(pos[j] - (i + 1))] = min(dp[i + 1][j + 1][0][x + abs(pos[j] - (i + 1))], dp[i][j][k][x]);
				}
			}
		}
	}

	int add = n * (n - 1) / 2 - tot * (n - tot) - tot * (tot - 1) / 2;

	int ans = inf;

	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n - tot; j++)
			ans = min(ans, dp[n][tot][j][i]);
		cout << add - ans << " ";
	}
	for (int i = n + 1; i <= n * (n - 1) / 2; i++)
		cout << add - ans << " ";

	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}


#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define F first
#define S second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const int inf = (int)1e8;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

const int N = 81;
const int M = 801;

vector < int > pos[2];
int n, a[N], cnt0[N][N], cnt1[N][N], prv[N][N][M], nxt[N][N][M];

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

	//cin.tie(NULL);
	//cout.tie(NULL);
	//ios_base::sync_with_stdio(false);

	//cout << setprecision(10) << fixed;

	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		pos[a[i]].pb(i);
	}

	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < sz(pos[0]); j++)
			cnt0[j + 1][i] = cnt0[j][i] + (pos[0][j] > i);
		for (int j = 0; j < sz(pos[1]); j++)
			cnt1[j + 1][i] = cnt1[j][i] + (pos[1][j] > i);
	}

	for (int j = 0; j < N; j++)
		for (int k = 0; k < N; k++)
			for (int x = 0; x < M; x++)
				prv[j][k][x] = nxt[j][k][x] = inf;

	prv[0][0][0] = 0;

	int tot = sz(pos[1]);

	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= min(i, tot); j++) {
			int zer = i - j;
			for (int k = 0; k <= min(i - j, n - tot); k++) {
				for (int x = 0; x < M; x++) {
					if (zer < sz(pos[0])) {
					    int newpos = pos[0][zer] + cnt1[j][pos[0][zer]];
					    if (i + 1 <= newpos && x + newpos - (i + 1) < M)
							nxt[j][k + 1][x + newpos - (i + 1)] = min(nxt[j][k + 1][x + newpos - (i + 1)], prv[j][k][x] + k);
					}
					if (j < sz(pos[1])) {
						int newpos = pos[1][j] + cnt0[zer][pos[1][j]];
						if (i + 1 <= newpos && x + newpos - (i + 1) < M)
							nxt[j + 1][0][x + newpos - (i + 1)] = min(nxt[j + 1][0][x + newpos - (i + 1)], prv[j][k][x]);
					}

				}
			}
		}
		for (int j = 0; j < N; j++) {
			for (int k = 0; k < N; k++) {
				for (int x = 0; x < M; x++) {
					swap(prv[j][k][x], nxt[j][k][x]);
					nxt[j][k][x] = inf;
				}
			}
		}
	}

	int add = n * (n - 1) / 2 - tot * (n - tot) - tot * (tot - 1) / 2;

	int ans = inf;

	for (int i = 0; i <= min(M - 1, n * (n - 1) / 2); i++) {
		for (int j = 0; j <= n - tot; j++)
			ans = min(ans, prv[tot][j][i]);
		cout << add - ans << " ";
	}
	for (int i = M; i <= n * (n - 1) / 2; i++)
		cout << add - ans << " ";

	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}


#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define F first
#define S second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const int inf = (int)1e8;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

const int N = 81;
const int M = 801;

vector < int > pos;
int n, a[N], prv[N][N][M], nxt[N][N][M];

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

	//cin.tie(NULL);
	//cout.tie(NULL);
	//ios_base::sync_with_stdio(false);

	//cout << setprecision(10) << fixed;

	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if (a[i])
			pos.pb(i);
	}

	for (int j = 0; j < N; j++)
		for (int k = 0; k < N; k++)
			for (int x = 0; x < M; x++)
				prv[j][k][x] = nxt[j][k][x] = inf;

	prv[0][0][0] = 0;

	int tot = sz(pos);

	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= min(i, tot); j++) {
			for (int k = 0; k <= min(i - j, n - tot); k++) {
				for (int x = 0; x < M; x++) {
					nxt[j][k + 1][x] = min(nxt[j][k + 1][x], prv[j][k][x] + k);
					if (j < tot && x + abs(pos[j] - (i + 1)) < M)
						nxt[j + 1][0][x + abs(pos[j] - (i + 1))] = min(nxt[j + 1][0][x + abs(pos[j] - (i + 1))], prv[j][k][x]);
				}
			}
		}
		for (int j = 0; j < N; j++) {
			for (int k = 0; k < N; k++) {
				for (int x = 0; x < M; x++) {
					swap(prv[j][k][x], nxt[j][k][x]);
					nxt[j][k][x] = inf;
				}
			}
		}
	}

	int add = n * (n - 1) / 2 - tot * (n - tot) - tot * (tot - 1) / 2;

	int ans = inf;

	for (int i = 0; i <= min(M - 1, n * (n - 1) / 2); i++) {
		for (int j = 0; j <= n - tot; j++)
			ans = min(ans, prv[tot][j][i]);
		cout << add - ans << " ";
	}
	for (int i = M; i <= n * (n - 1) / 2; i++)
		cout << add - ans << " ";

	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}


#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define F first
#define S second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const int inf = (int)1e8;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

const int N = 81;
const int M = 801;

vector < int > pos;
int n, a[N], prv[N][N][M], nxt[N][N][M];

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

	//cin.tie(NULL);
	//cout.tie(NULL);
	//ios_base::sync_with_stdio(false);

	//cout << setprecision(10) << fixed;

	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if (a[i])
			pos.pb(i);
	}

	for (int j = 0; j < N; j++)
		for (int k = 0; k < N; k++)
			for (int x = 0; x < M; x++)
				prv[j][k][x] = nxt[j][k][x] = inf;

	prv[0][0][0] = 0;

	int tot = sz(pos);

	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= min(i, tot); j++) {
			for (int k = 0; k <= min(i - j, n - tot); k++) {
				for (int x = 0; x < M; x++) {
					nxt[j][k + 1][x] = min(nxt[j][k + 1][x], prv[j][k][x] + k);
					if (x + abs(pos[j] - (i + 1)) < M)
						nxt[j + 1][0][x + abs(pos[j] - (i + 1))] = min(nxt[j + 1][0][x + abs(pos[j] - (i + 1))], prv[j][k][x]);
				}
			}
		}
		for (int j = 0; j < N; j++) {
			for (int k = 0; k < N; k++) {
				for (int x = 0; x < M; x++) {
					swap(prv[j][k][x], nxt[j][k][x]);
					nxt[j][k][x] = inf;
				}
			}
		}
	}

	int add = n * (n - 1) / 2 - tot * (n - tot) - tot * (tot - 1) / 2;

	int ans = inf;

	for (int i = 0; i <= min(M - 1, n * (n - 1) / 2); i++) {
		for (int j = 0; j <= n - tot; j++)
			ans = min(ans, prv[tot][j][i]);
		cout << add - ans << " ";
	}
	for (int i = M; i <= n * (n - 1) / 2; i++)
		cout << add - ans << " ";

	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}


#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define F first
#define S second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const int inf = (int)1e8;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

const int N = 81;

vector < int > pos[2];
int n, a[N], cnt0[N][N], cnt1[N][N], dp[N][N][N][2 * N];

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

	//cin.tie(NULL);
	//cout.tie(NULL);
	//ios_base::sync_with_stdio(false);

	//cout << setprecision(10) << fixed;

	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		pos[a[i]].pb(i);
	}

	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < sz(pos[0]); j++)
			cnt0[j + 1][i] = cnt0[j][i] + (pos[0][j] > i);
		for (int j = 0; j < sz(pos[1]); j++)
			cnt1[j + 1][i] = cnt1[j][i] + (pos[1][j] > i);
	}

	for (int i = 0; i < N; i++)
		for (int j = 0; j < N; j++)
			for (int k = 0; k < N; k++)
				for (int x = 0; x < N; x++)
					dp[i][j][k][x] = inf;

	dp[0][0][0][0] = 0;

	int tot = sz(pos[1]);

	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= min(i, tot); j++) {
			int zer = i - j;
			for (int k = 0; k <= min(i - j, n - tot); k++) {
				for (int x = 0; x <= n + n; x++) {
					if (zer < sz(pos[0])) {
					    int newpos = pos[0][zer] + cnt1[j][pos[0][zer]];
					    if (i + 1 <= newpos && x + newpos - (i + 1) <= n + n)
							dp[i + 1][j][k + 1][x + newpos - (i + 1)] = min(dp[i + 1][j][k + 1][x + newpos - (i + 1)], dp[i][j][k][x] + k);
					}
					if (j < sz(pos[1])) {
						int newpos = pos[1][j] + cnt0[zer][pos[1][j]];
						if (i + 1 <= newpos && x + newpos - (i + 1) <= n + n)
							dp[i + 1][j + 1][0][x + newpos - (i + 1)] = min(dp[i + 1][j + 1][0][x + newpos - (i + 1)], dp[i][j][k][x]);
					}

				}
			}
		}
	}

	int add = n * (n - 1) / 2 - tot * (n - tot) - tot * (tot - 1) / 2;

	int ans = inf;

	for (int i = 0; i <= min(n + n, n * (n - 1) / 2); i++) {
		for (int j = 0; j <= n - tot; j++)
			ans = min(ans, dp[n][tot][j][i]);
		cout << add - ans << " ";
	}
	for (int i = n + n + 1; i <= n * (n - 1) / 2; i++)
		cout << add - ans << " ";

	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}


#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define F first
#define S second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const int inf = (int)1e8;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

const int N = 81;
const int M = 1601;

vector < int > pos[2];
int n, a[N], cnt0[N][N], cnt1[N][N], prv[N][N][M], nxt[N][N][M];

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

	//cin.tie(NULL);
	//cout.tie(NULL);
	//ios_base::sync_with_stdio(false);

	//cout << setprecision(10) << fixed;

	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		pos[a[i]].pb(i);
	}

	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < sz(pos[0]); j++)
			cnt0[j + 1][i] = cnt0[j][i] + (pos[0][j] > i);
		for (int j = 0; j < sz(pos[1]); j++)
			cnt1[j + 1][i] = cnt1[j][i] + (pos[1][j] > i);
	}

	for (int j = 0; j < N; j++)
		for (int k = 0; k < N; k++)
			for (int x = 0; x < M; x++)
				prv[j][k][x] = nxt[j][k][x] = inf;

	prv[0][0][0] = 0;

	int tot = sz(pos[1]);

	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= min(i, tot); j++) {
			int zer = i - j;
			for (int k = 0; k <= min(i - j, n - tot); k++) {
				for (int x = 0; x < M; x++) {
					if (zer < sz(pos[0])) {
					    int newpos = pos[0][zer] + cnt1[j][pos[0][zer]];
					    if (i + 1 <= newpos && x + newpos - (i + 1) < M)
							nxt[j][k + 1][x + newpos - (i + 1)] = min(nxt[j][k + 1][x + newpos - (i + 1)], prv[j][k][x] + k);
					}
					if (j < sz(pos[1])) {
						int newpos = pos[1][j] + cnt0[zer][pos[1][j]];
						if (i + 1 <= newpos && x + newpos - (i + 1) < M)
							nxt[j + 1][0][x + newpos - (i + 1)] = min(nxt[j + 1][0][x + newpos - (i + 1)], prv[j][k][x]);
					}

				}
			}
		}
		for (int j = 0; j < N; j++) {
			for (int k = 0; k < N; k++) {
				for (int x = 0; x < M; x++) {
					swap(prv[j][k][x], nxt[j][k][x]);
					nxt[j][k][x] = inf;
				}
			}
		}
	}

	int add = n * (n - 1) / 2 - tot * (n - tot) - tot * (tot - 1) / 2;

	int ans = inf;

	for (int i = 0; i <= min(M - 1, n * (n - 1) / 2); i++) {
		for (int j = 0; j <= n - tot; j++)
			ans = min(ans, prv[tot][j][i]);
		cout << add - ans << " ";
	}
	for (int i = M; i <= n * (n - 1) / 2; i++)
		cout << add - ans << " ";

	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}


#include <bits/stdc++.h>

using namespace std;
const int c=82;
int n, dp[c][c*c][c], db, k, si;
bool v[c];
vector<int> sz;
int main()
{
    cin >> n, k=n*(n-1)/2;
    for (int i=1; i<=n; i++) {
        cin >> v[i];
        if (!v[i]) db++;
        else sz.push_back(i);
    }
    si=sz.size();
    for (int i=0; i<=k; i++) for (int j=1; j<=n+1; j++) {
        dp[0][i][j]=(j-1)*(j-1);
        for (int t=1; t<=si; t++) dp[t][i][j]=c*c;
    }
    for (int i=1; i<=si; i++) {
        for (int pos=1; pos<=n+1; pos++) {
            for (int h=1; h<pos; h++) {
                for (int st=abs(sz[i-1]-h); st<=k; st++) {
                    dp[i][st][pos]=min(dp[i][st][pos], (pos-h-1)*(pos-h-1)+dp[i-1][st-abs(sz[i-1]-h)][h]);
                }
            }
        }
    }
    for (int i=0; i<=k; i++) cout << (db*db-dp[si][i][n+1])/2 << " ";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
const int c=82;
int n, dp[c][c*c][c], db, k, si;
bool v[c];
vector<int> sz;
int main()
{
    cin >> n, k=n*(n-1)/2;
    for (int i=1; i<=n; i++) {
        cin >> v[i];
        if (!v[i]) db++;
        else sz.push_back(i), si++;
    }
    for (int i=0; i<=k; i++) for (int j=1; j<=n+1; j++) {
        dp[0][i][j]=(j-1)*(j-1);
        for (int t=1; t<=si; t++) dp[t][i][j]=c*c;
    }
    for (int i=1; i<=si; i++) for (int pos=i+1; pos<=n+1; pos++) for (int h=i; h<pos; h++) for (int st=abs(sz[i-1]-h); st<=k; st++) dp[i][st][pos]=min(dp[i][st][pos], (pos-h-1)*(pos-h-1)+dp[i-1][st-abs(sz[i-1]-h)][h]);
    for (int i=0; i<=k; i++) cout << (db*db-dp[si][i][n+1])/2 << " ";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
const int c=82;
int n, dp[c][c*c][c], db, k, si;
bool v[c];
vector<int> sz;
int main()
{
    cin >> n, k=n*(n-1)/2;
    for (int i=1; i<=n; i++) {
        cin >> v[i];
        if (!v[i]) db++;
        else sz.push_back(i);
    }
    si=sz.size();
    for (int i=0; i<=k; i++) for (int j=1; j<=n+1; j++) {
        dp[0][i][j]=(j-1)*(j-1);
        for (int t=1; t<=si; t++) dp[t][i][j]=c*c;
    }
    for (int i=1; i<=si; i++) {
        for (int pos=i+1; pos<=n+1; pos++) {
            for (int h=i; h<pos; h++) {
                for (int st=abs(sz[i-1]-h); st<=k; st++) {
                    dp[i][st][pos]=min(dp[i][st][pos], (pos-h-1)*(pos-h-1)+dp[i-1][st-abs(sz[i-1]-h)][h]);
                }
            }
        }
    }
    for (int i=0; i<=k; i++) cout << (db*db-dp[si][i][n+1])/2 << " ";
    return 0;
}


#include <bits/stdc++.h>
#define maxn 82

using namespace std;

int n;
int pos[maxn], x;
int cnt, ans;
int f[maxn][maxn][maxn * maxn];

int main(){
	scanf("%d", &n);
	for(int i = 1;i <= n;i++){
		scanf("%d", &x);
		if(x){
			pos[++cnt] = i;
		}else{
			ans++;
		}
	}
	ans = ans * (ans - 1) / 2;
	memset(f, 0x3f, sizeof(f));
	f[0][0][0] = 0;
	for(int i = 1;i <= cnt;i++){
		for(int j = 1;j <= n;j++){
			for(int k = 0;k <= n * (n - 1) / 2;k++){
				if(k) f[i][j][k] = f[i][j][k - 1];
				for(int t = 0;t < j;t++){
					if(k - abs(pos[i] - j) >= 0) f[i][j][k] = min(f[i][j][k], f[i - 1][t][k - abs(pos[i] - j)] + (j - t - 1) * (j - t - 2) / 2);
				}
			}
		}
	}
	for(int i = 0;i <= n * (n - 1) / 2;i++){
		int sum = 1e9;
		for(int j = 1;j <= n;j++) sum = min(sum, f[cnt][j][i] + (n - j) * (n - j - 1) / 2);//debug:最后还剩一段0 忘记考虑
		printf("%d ", ans - sum);
	}
}


#include <bits/stdc++.h>
#define maxn 82

using namespace std;

int n;
int pos[maxn], x;
int cnt, ans;
int f[maxn][maxn][maxn * maxn];

int main(){
	scanf("%d", &n);
	for(int i = 1;i <= n;i++){
		scanf("%d", &x);
		if(x){
			pos[++cnt] = i;
		}else{
			ans++;
		}
	}
	if(!cnt){//debug：特判
		for(int i = 0;i <= n * (n - 1) / 2;i++) printf("0 ");
		return 0;
	}
	ans = ans * (ans - 1) / 2;
	memset(f, 0x3f, sizeof(f));
	f[0][0][0] = 0;
	for(int i = 1;i <= cnt;i++){
		for(int j = 1;j <= n;j++){
			for(int k = 0;k <= n * (n - 1) / 2;k++){
				if(k) f[i][j][k] = f[i][j][k - 1];
				for(int t = 0;t < j;t++){
					if(k - abs(pos[i] - j) >= 0) f[i][j][k] = min(f[i][j][k], f[i - 1][t][k - abs(pos[i] - j)] + (j - t - 1) * (j - t - 2) / 2);
				}
			}
		}
	}
	for(int i = 0;i <= n * (n - 1) / 2;i++){
		int sum = 1e9;
		for(int j = 1;j <= n;j++) sum = min(sum, f[cnt][j][i] + (n - j) * (n - j - 1) / 2);//debug:最后还剩一段0 忘记考虑
		printf("%d ", ans - sum);
	}
}


#include <bits/stdc++.h>
#define maxn 82

using namespace std;

int n;
int pos[maxn], x;
int cnt, ans;
int f[maxn][maxn][maxn * maxn];

int main(){
	scanf("%d", &n);
	for(int i = 1;i <= n;i++){
		scanf("%d", &x);
		if(x){
			pos[++cnt] = i;
		}else{
			ans++;
		}
	}
	ans = ans * (ans - 1) / 2;
	memset(f, 0x3f, sizeof(f));
	f[0][0][0] = 0;
	for(int i = 1;i <= cnt;i++){
		for(int j = 1;j <= n;j++){
			for(int k = 0;k <= n * (n - 1) / 2;k++){
				f[i][j][k] = f[i][j][k - 1];
				for(int t = 0;t < j;t++){
					if(k - abs(pos[i] - j) >= 0) f[i][j][k] = min(f[i][j][k], f[i - 1][t][k - abs(pos[i] - j)] + (j - t - 1) * (j - t - 2) / 2);
				}
			}
		}
	}
	for(int i = 0;i <= n * (n - 1) / 2;i++){
		int sum = 1e9;
		for(int j = 1;j <= n;j++) sum = min(sum, f[cnt][j][i]);
		printf("%d ", ans - sum);
	}
}


#include <bits/stdc++.h>
#define maxn 82

using namespace std;

int n;
int pos[maxn], x;
int cnt, ans;
int f[maxn][maxn][maxn * maxn];

int main(){
	scanf("%d", &n);
	for(int i = 1;i <= n;i++){
		scanf("%d", &x);
		if(x){
			pos[++cnt] = i;
		}else{
			ans++;
		}
	}
	if(!cnt) return printf("0"), 0;//debug:特判
	ans = ans * (ans - 1) / 2;
	memset(f, 0x3f, sizeof(f));
	f[0][0][0] = 0;
	for(int i = 1;i <= cnt;i++){
		for(int j = 1;j <= n;j++){
			for(int k = 0;k <= n * (n - 1) / 2;k++){
				if(k) f[i][j][k] = f[i][j][k - 1];
				for(int t = 0;t < j;t++){
					if(k - abs(pos[i] - j) >= 0) f[i][j][k] = min(f[i][j][k], f[i - 1][t][k - abs(pos[i] - j)] + (j - t - 1) * (j - t - 2) / 2);
				}
			}
		}
	}
	for(int i = 0;i <= n * (n - 1) / 2;i++){
		int sum = 1e9;
		for(int j = 1;j <= n;j++) sum = min(sum, f[cnt][j][i] + (n - j) * (n - j - 1) / 2);//debug:最后还剩一段0 忘记考虑
		printf("%d ", ans - sum);
	}
}


#include <bits/stdc++.h>
#define maxn 82

using namespace std;

int n;
int pos[maxn], x;
int cnt, ans;
int f[maxn][maxn][maxn * maxn];

int main(){
	scanf("%d", &n);
	for(int i = 1;i <= n;i++){
		scanf("%d", &x);
		if(x){
			pos[++cnt] = i;
		}else{
			ans++;
		}
	}
	if(!cnt){//debug：特判
		for(int i = 0;i <= n;i++) printf("0 ");
		return 0;
	}
	ans = ans * (ans - 1) / 2;
	memset(f, 0x3f, sizeof(f));
	f[0][0][0] = 0;
	for(int i = 1;i <= cnt;i++){
		for(int j = 1;j <= n;j++){
			for(int k = 0;k <= n * (n - 1) / 2;k++){
				if(k) f[i][j][k] = f[i][j][k - 1];
				for(int t = 0;t < j;t++){
					if(k - abs(pos[i] - j) >= 0) f[i][j][k] = min(f[i][j][k], f[i - 1][t][k - abs(pos[i] - j)] + (j - t - 1) * (j - t - 2) / 2);
				}
			}
		}
	}
	for(int i = 0;i <= n * (n - 1) / 2;i++){
		int sum = 1e9;
		for(int j = 1;j <= n;j++) sum = min(sum, f[cnt][j][i] + (n - j) * (n - j - 1) / 2);//debug:最后还剩一段0 忘记考虑
		printf("%d ", ans - sum);
	}
}


#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <map>
#include <assert.h>
#include <fstream>
#include <tuple>
#include <queue>
#include <unordered_set>
#include <cstdlib>
#include <random>
#include <iomanip>

using namespace std;

#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()

int dp[82][82][80 * 80 / 2];

int main() {
    // freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    srand(228);

    int n;
    cin >> n;

    vector<int> a(n);
    int sum = 0;
    vector<int> sumPr(n);
    vector<int> poss;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i];

        if (a[i])
            poss.push_back(i);

        if (i)
            sumPr[i] = sumPr[i - 1];
        sumPr[i] += a[i];
    }

    for (int i = 0; i <= n; ++i) {
        for (int num = 0; num <= sum; ++num) {
            for (int e = 0; e <= n * (n + 1) / 2; ++e)
                dp[i][num][e] = (int) -1e9;
        }
    }

    dp[0][0][0] = 0;

    for (int i = 0; i < n; ++i) {
        for (int num = 0; num < sum; ++num) {
            for (int e = 0; e <= n * (n + 1) / 2; ++e) {
                if (dp[i][num][e] == (int) -1e9)
                    continue;

                for (int pos = i; pos < n; ++pos) {
                    if (((n - pos - 1) - (sum - num - 1)) < 0)
                        break;

                    int nw = (pos - i) * ((n - pos - 1) - (sum - num - 1)) + dp[i][num][e];

                    dp[pos + 1][num + 1][e + abs(pos - poss[num])] = max(
                        dp[pos + 1][num + 1][e + abs(pos - poss[num])],
                        nw
                    );
                }
            }
        }
    }

    int mx = 0;
    for (int e = 0; e <= n * (n - 1) / 2; ++e) {
        for (int j = 0; j <= n; ++j)
            mx = max(mx, dp[j][sum][e]);
        cout << mx << " ";
        // cout << dp[n][sum][e] << " ";
    }
    cout << "\n";
}


#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <map>
#include <assert.h>
#include <fstream>
#include <tuple>
#include <queue>
#include <unordered_set>
#include <cstdlib>
#include <random>
#include <iomanip>

using namespace std;

#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()

int dp[82][82][82 * 82 / 2];

int main() {
    // freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    srand(228);

    int n;
    cin >> n;

    vector<int> a(n);
    int sum = 0;
    vector<int> sumPr(n);
    vector<int> poss;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i];

        if (a[i])
            poss.push_back(i);

        if (i)
            sumPr[i] = sumPr[i - 1];
        sumPr[i] += a[i];
    }

    for (int i = 0; i <= n; ++i) {
        for (int num = 0; num <= min(i, sum); ++num) {
            for (int e = 0; e <= min(n * num, n * (n - 1) / 2); ++e)
                dp[i][num][e] = (int) -1e9;
        }
    }

    dp[0][0][0] = 0;

    for (int i = 0; i < n; ++i) {
        for (int num = 0; num < min(i + 1, sum); ++num) {
            for (int e = 0; e <= min(n * num, n * (n - 1) / 2); ++e) {
                if (dp[i][num][e] == (int) -1e9)
                    continue;

                for (int pos = i; pos < n; ++pos) {
                    int nw = (pos - i) * ((n - pos - 1) - (sum - num - 1)) + dp[i][num][e];

                    dp[pos + 1][num + 1][e + abs(pos - poss[num])] = max(
                        dp[pos + 1][num + 1][e + abs(pos - poss[num])],
                        nw
                    );
                }
            }
        }
    }

    int mx = 0;
    for (int e = 0; e <= n * (n - 1) / 2; ++e) {
        for (int j = 0; j <= n; ++j)
            mx = max(mx, dp[j][sum][e]);
        cout << mx << " ";
    }
    cout << "\n";
}


#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <map>
#include <assert.h>
#include <fstream>
#include <tuple>
#include <queue>
#include <unordered_set>
#include <cstdlib>
#include <random>
#include <iomanip>

using namespace std;

#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()

int dp[82][82][82 * 82 / 2];

int main() {
    // freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    srand(228);

    int n;
    cin >> n;

    vector<int> a(n);
    int sum = 0;
    vector<int> sumPr(n);
    vector<int> poss;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i];

        if (a[i])
            poss.push_back(i);

        if (i)
            sumPr[i] = sumPr[i - 1];
        sumPr[i] += a[i];
    }

    for (int i = 0; i <= n; ++i) {
        for (int num = 0; num <= sum; ++num) {
            for (int e = 0; e <= n * (n + 1) / 2; ++e)
                dp[i][num][e] = (int) -1e9;
        }
    }

    dp[0][0][0] = 0;

    for (int i = 0; i < n; ++i) {
        for (int num = 0; num < sum; ++num) {
            for (int e = 0; e <= n * (n + 1) / 2; ++e) {
                if (dp[i][num][e] == (int) -1e9)
                    continue;

                for (int pos = i; pos < n; ++pos) {
                    // if (((n - pos - 1) - (sum - num - 1)) < 0)
                    //     break;

                    int nw = (pos - i) * ((n - pos - 1) - (sum - num - 1)) + dp[i][num][e];

                    dp[pos + 1][num + 1][e + abs(pos - poss[num])] = max(
                        dp[pos + 1][num + 1][e + abs(pos - poss[num])],
                        nw
                    );
                }
            }
        }
    }

    int mx = 0;
    for (int e = 0; e <= n * (n - 1) / 2; ++e) {
        for (int j = 0; j <= n; ++j)
            mx = max(mx, dp[j][sum][e]);
        cout << mx << " ";
        // cout << dp[n][sum][e] << " ";
    }
    cout << "\n";
}


#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <map>
#include <assert.h>
#include <fstream>
#include <tuple>
#include <queue>
#include <unordered_set>
#include <cstdlib>
#include <random>
#include <iomanip>

using namespace std;

#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()

int dp[82][82][80 * 80 / 2];

int main() {
    // freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    srand(228);

    int n;
    cin >> n;

    vector<int> a(n);
    int sum = 0;
    vector<int> sumPr(n);
    vector<int> poss;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i];

        if (a[i])
            poss.push_back(i);

        if (i)
            sumPr[i] = sumPr[i - 1];
        sumPr[i] += a[i];
    }

    for (int i = 0; i <= n; ++i) {
        for (int num = 0; num <= sum; ++num) {
            for (int e = 0; e <= n * (n + 1) / 2; ++e)
                dp[i][num][e] = (int) -1e9;
        }
    }

    dp[0][0][0] = 0;

    for (int i = 0; i < n; ++i) {
        for (int num = 0; num <= sum; ++num) {
            for (int e = 0; e <= n * (n + 1) / 2; ++e) {
                if (dp[i][num][e] == (int) -1e9)
                    continue;

                // if (e == 0) {
                //     cout << i << " " << num << " " << dp[i][num][e] << "\n";
                // }

                // int kek = (i ? sumPr[i - 1] : 0) - num, lol = 0;
                for (int pos = i; pos < n; ++pos) {
                    if (((n - pos - 1) - (sum - num - 1)) < 0)
                        break;

                    // lol += kek;

                    int nw = (pos - i) * ((n - pos - 1) - (sum - num - 1)) + dp[i][num][e];

                    // int f = 0;
                    // if (num + 1 > sumPr[pos]) {

                    // }

                    dp[pos + 1][num + 1][e + abs(pos - poss[num])] = max(
                        dp[pos + 1][num + 1][e + abs(pos - poss[num])],
                        nw
                    );

                    // kek += a[pos];
                }
            }
        }
    }

    int mx = 0;
    for (int e = 0; e <= n * (n + 1) / 2; ++e) {
        for (int j = 0; j <= n; ++j)
            mx = max(mx, dp[j][sum][e]);
        cout << mx << " ";
        // cout << dp[n][sum][e] << " ";
    }
    cout << "\n";
}


#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <map>
#include <assert.h>
#include <fstream>
#include <tuple>
#include <queue>
#include <unordered_set>
#include <cstdlib>
#include <random>
#include <iomanip>

using namespace std;

#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()

int dp[82][82][82 * 82 / 2];

int main() {
    // freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    srand(228);

    int n;
    cin >> n;

    vector<int> a(n);
    int sum = 0;
    vector<int> sumPr(n);
    vector<int> poss;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i];

        if (a[i])
            poss.push_back(i);

        if (i)
            sumPr[i] = sumPr[i - 1];
        sumPr[i] += a[i];
    }

    for (int i = 0; i <= n; ++i) {
        for (int num = 0; num <= i; ++num) {
            for (int e = 0; e <= n * i; ++e)
                dp[i][num][e] = (int) -1e9;
        }
    }

    dp[0][0][0] = 0;

    for (int i = 0; i < n; ++i) {
        for (int num = 0; num <= i; ++num) {
            for (int e = 0; e <= n * i; ++e) {
                if (dp[i][num][e] == (int) -1e9)
                    continue;

                for (int pos = i; pos < n; ++pos) {
                    int nw = (pos - i) * ((n - pos - 1) - (sum - num - 1)) + dp[i][num][e];

                    dp[pos + 1][num + 1][e + abs(pos - poss[num])] = max(
                        dp[pos + 1][num + 1][e + abs(pos - poss[num])],
                        nw
                    );
                }
            }
        }
    }

    int mx = 0;
    for (int e = 0; e <= n * (n - 1) / 2; ++e) {
        for (int j = 0; j <= n; ++j)
            mx = max(mx, dp[j][sum][e]);
        cout << mx << " ";
    }
    cout << "\n";
}


#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <map>
#include <assert.h>
#include <fstream>
#include <tuple>
#include <queue>
#include <unordered_set>
#include <cstdlib>
#include <random>
#include <iomanip>

using namespace std;

#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()

int dp[82][82][82 * 82 / 2];

int main() {
    // freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    srand(228);

    int n;
    cin >> n;

    vector<int> a(n);
    int sum = 0;
    vector<int> sumPr(n);
    vector<int> poss;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i];

        if (a[i])
            poss.push_back(i);

        if (i)
            sumPr[i] = sumPr[i - 1];
        sumPr[i] += a[i];
    }

    for (int i = 0; i <= n; ++i) {
        for (int num = 0; num <= i; ++num) {
            for (int e = 0; e <= min(n * num, n * (n - 1) / 2); ++e)
                dp[i][num][e] = (int) -1e9;
        }
    }

    dp[0][0][0] = 0;

    for (int i = 0; i < n; ++i) {
        for (int num = 0; num <= i; ++num) {
            for (int e = 0; e <= min(n * num, n * (n - 1) / 2); ++e) {
                if (dp[i][num][e] == (int) -1e9)
                    continue;

                for (int pos = i; pos < n; ++pos) {
                    int nw = (pos - i) * ((n - pos - 1) - (sum - num - 1)) + dp[i][num][e];

                    dp[pos + 1][num + 1][e + abs(pos - poss[num])] = max(
                        dp[pos + 1][num + 1][e + abs(pos - poss[num])],
                        nw
                    );
                }
            }
        }
    }

    int mx = 0;
    for (int e = 0; e <= n * (n - 1) / 2; ++e) {
        for (int j = 0; j <= n; ++j)
            mx = max(mx, dp[j][sum][e]);
        cout << mx << " ";
    }
    cout << "\n";
}


#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <map>
#include <assert.h>
#include <fstream>
#include <tuple>
#include <queue>
#include <unordered_set>
#include <cstdlib>
#include <random>
#include <iomanip>

using namespace std;

#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()

int dp[82][82][80 * 80 / 2];

int main() {
    // freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    srand(228);

    int n;
    cin >> n;

    vector<int> a(n);
    int sum = 0;
    vector<int> sumPr(n);
    vector<int> poss;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i];

        if (a[i])
            poss.push_back(i);

        if (i)
            sumPr[i] = sumPr[i - 1];
        sumPr[i] += a[i];
    }

    for (int i = 0; i <= n; ++i) {
        for (int num = 0; num <= sum; ++num) {
            for (int e = 0; e <= n * (n + 1) / 2; ++e)
                dp[i][num][e] = (int) -1e9;
        }
    }

    dp[0][0][0] = 0;

    for (int i = 0; i < n; ++i) {
        for (int num = 0; num < sum; ++num) {
            for (int e = 0; e <= n * (n + 1) / 2; ++e) {
                if (dp[i][num][e] == (int) -1e9)
                    continue;

                for (int pos = i; pos < n; ++pos) {
                    // if (((n - pos - 1) - (sum - num - 1)) < 0)
                    //     break;

                    int nw = (pos - i) * ((n - pos - 1) - (sum - num - 1)) + dp[i][num][e];

                    dp[pos + 1][num + 1][e + abs(pos - poss[num])] = max(
                        dp[pos + 1][num + 1][e + abs(pos - poss[num])],
                        nw
                    );
                }
            }
        }
    }

    int mx = 0;
    for (int e = 0; e <= n * (n - 1) / 2; ++e) {
        for (int j = 0; j <= n; ++j)
            mx = max(mx, dp[j][sum][e]);
        cout << mx << " ";
        // cout << dp[n][sum][e] << " ";
    }
    cout << "\n";
}


#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <map>
#include <assert.h>
#include <fstream>
#include <tuple>
#include <queue>
#include <unordered_set>
#include <cstdlib>
#include <random>
#include <iomanip>

using namespace std;

#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()

int dp[82][82][80 * 80 / 2];

int main() {
    // freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    srand(228);

    int n;
    cin >> n;

    vector<int> a(n);
    int sum = 0;
    vector<int> sumPr(n);
    vector<int> poss;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i];

        if (a[i])
            poss.push_back(i);

        if (i)
            sumPr[i] = sumPr[i - 1];
        sumPr[i] += a[i];
    }

    for (int i = 0; i <= n; ++i) {
        for (int num = 0; num <= sum; ++num) {
            for (int e = 0; e <= n * (n + 1) / 2; ++e)
                dp[i][num][e] = (int) -1e9;
        }
    }

    dp[0][0][0] = 0;

    for (int i = 0; i < n; ++i) {
        for (int num = 0; num < sum; ++num) {
            for (int e = 0; e <= n * (n + 1) / 2; ++e) {
                if (dp[i][num][e] == (int) -1e9)
                    continue;

                for (int pos = i; pos < n; ++pos) {
                    if (((n - pos - 1) - (sum - num - 1)) < 0)
                        break;

                    int nw = (pos - i) * ((n - pos - 1) - (sum - num - 1)) + dp[i][num][e];

                    dp[pos + 1][num + 1][e + abs(pos - poss[num])] = max(
                        dp[pos + 1][num + 1][e + abs(pos - poss[num])],
                        nw
                    );
                }
            }
        }
    }

    int mx = 0;
    for (int e = 0; e <= n * (n + 1) / 2; ++e) {
        for (int j = 0; j <= n; ++j)
            mx = max(mx, dp[j][sum][e]);
        cout << mx << " ";
        // cout << dp[n][sum][e] << " ";
    }
    cout << "\n";
}


#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 2020000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr << " ";
	}
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){
	cout << "debug: " << a << " " << b << "\n";
}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << "debug: " << a << " " << b << " " << c << "\n";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
//const int mod = 1e9 + 7;
const int mod = 998244353;

int dp[42][42][3300];

int main(){
	int n; cin >> n;
	vl a(n); rep(i,n) cin >> a[i];
	vl b;
	int cnt = 0;
	int sum = 0;
	rep(i,n){
		if(a[i] == 0) cnt++, sum++;
		else b.push_back(cnt), cnt = 0;
	}
	b.push_back(cnt);
	int m = b.size();
	int L = sum * (sum-1) / 2;
	vl acc(m+1,0); rep(i,m) acc[i+1] = acc[i] + b[i];
	rep(i,m+1) rep(j,sum+1) rep(k,L+1) dp[i][j][k] = inf;
	dp[0][0][0] = 0;
	rep(i,m){
		rep(j,sum+1){
			rep(k,L+1){
				int id = i+1;
				int s = 0;
				for(int l=0; l+j<=sum; l++){
					if(l+j <= acc[i+1]){
						chmin(dp[i+1][l+j][k+acc[i+1]-l-j], dp[i][j][k] + l*(l-1)/2);
					}else{
						while(acc[id] - j < l) id++;
						s += id - (i+1);
						chmin(dp[i+1][l+j][k+s], dp[i][j][k] + l*(l-1)/2);
					}
				}
			}
		}
	}
	rep(i,L){
		chmin(dp[m][sum][i+1], dp[m][sum][i]);
	}
	rep(i,L+1) cout << L - dp[m][sum][i] << " ";
	for(int i=L+1; i<=n*(n-1)/2; i++) cout << L - dp[m][sum][L] << " ";
	cout << "\n";
}


#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 2020000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr << " ";
	}
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){
	cout << "debug: " << a << " " << b << "\n";
}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << "debug: " << a << " " << b << " " << c << "\n";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
//const int mod = 1e9 + 7;
const int mod = 998244353;

int dp[81][81][3300];

int main(){
	int n; cin >> n;
	vl a(n); rep(i,n) cin >> a[i];
	vl b;
	int cnt = 0;
	int sum = 0;
	rep(i,n){
		if(a[i] == 0) cnt++, sum++;
		else b.push_back(cnt), cnt = 0;
	}
	b.push_back(cnt);
	int m = b.size();
	int L = sum * (sum-1) / 2;
	vl acc(m+1,0); rep(i,m) acc[i+1] = acc[i] + b[i];
	rep(i,m+1) rep(j,sum+1) rep(k,L+1) dp[i][j][k] = inf;
	dp[0][0][0] = 0;
	rep(i,m){
		rep(j,sum+1){
			rep(k,L+1){
				for(int l=0; l+j<=sum; l++){
					chmin(dp[i+1][l+j][k+abs(acc[i+1]-l-j)], dp[i][j][k] + l*(l-1)/2);
				}
			}
		}
	}
	rep(i,L){
		chmin(dp[m][sum][i+1], dp[m][sum][i]);
	}
	rep(i,L+1) cout << L - dp[m][sum][i] << " ";
	for(int i=L+1; i<=n*(n-1)/2; i++) cout << L - dp[m][sum][L] << " ";
	cout << "\n";
}


#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 2020000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr << " ";
	}
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){
	cout << "debug: " << a << " " << b << "\n";
}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << "debug: " << a << " " << b << " " << c << "\n";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
//const int mod = 1e9 + 7;
const int mod = 998244353;

int dp[81][81][3300];

int main(){
	int n; cin >> n;
	vl a(n); rep(i,n) cin >> a[i];
	vl b;
	int cnt = 0;
	int sum = 0;
	rep(i,n){
		if(a[i] == 0) cnt++, sum++;
		else b.push_back(cnt), cnt = 0;
	}
	b.push_back(cnt);
	int m = b.size();
	int L = sum * (sum-1) / 2;
	vl acc(m+1,0); rep(i,m) acc[i+1] = acc[i] + b[i];
	rep(i,m+1) rep(j,sum+1) rep(k,L+1) dp[i][j][k] = inf;
	dp[0][0][0] = 0;
	rep(i,m){
		rep(j,sum+1){
			rep(k,L+1){
				int id = i+1;
				int s = 0;
				for(int l=0; l+j<=sum; l++){
					if(l+j <= acc[i+1]){
						chmin(dp[i+1][l+j][k+acc[i+1]-l-j], dp[i][j][k] + l*(l-1)/2);
					}else{
						while(acc[id] - j < l) id++;
						s += id - (i+1);
						chmin(dp[i+1][l+j][k+s], dp[i][j][k] + l*(l-1)/2);
					}
				}
			}
		}
	}
	rep(i,L){
		chmin(dp[m][sum][i+1], dp[m][sum][i]);
	}
	rep(i,L+1) cout << L - dp[m][sum][i] << " ";
	for(int i=L+1; i<=n*(n-1)/2; i++) cout << L - dp[m][sum][L] << " ";
	cout << "\n";
}


#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 2020000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr << " ";
	}
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){
	cout << "debug: " << a << " " << b << "\n";
}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << "debug: " << a << " " << b << " " << c << "\n";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
//const int mod = 1e9 + 7;
const int mod = 998244353;

int dp[81][81][3300];

int main(){
	int n; cin >> n;
	vl a(n); rep(i,n) cin >> a[i];
	vl b;
	int cnt = 0;
	int sum = 0;
	rep(i,n){
		if(a[i] == 0) cnt++, sum++;
		else b.push_back(cnt), cnt = 0;
	}
	b.push_back(cnt);
	int m = b.size();
	int L = sum * (sum-1) / 2;
	vl acc(m+1,0); rep(i,m) acc[i+1] = acc[i] + b[i];
	rep(i,m+1) rep(j,sum+1) rep(k,L+1) dp[i][j][k] = inf;
	dp[0][0][0] = 0;
	rep(i,m){
		rep(j,sum+1){
			rep(k,L+1){
				int id = i+1;
				int s = 0;
				for(int l=0; l+j<=sum; l++){
					if(l+j <= acc[i+1]){
						chmin(dp[i+1][l+j][k+acc[i+1]-l-j], dp[i][j][k] + l*(l-1)/2);
					}else{
						while(acc[id] - j < l) id++;
						s += id - (i+1);
						if(k+s > L) break;
						chmin(dp[i+1][l+j][k+s], dp[i][j][k] + l*(l-1)/2);
					}
				}
			}
		}
	}
	rep(i,L){
		chmin(dp[m][sum][i+1], dp[m][sum][i]);
	}
	rep(i,L+1) cout << L - dp[m][sum][i] << " ";
	for(int i=L+1; i<=n*(n-1)/2; i++) cout << L - dp[m][sum][L] << " ";
	cout << "\n";
}


#pragma GCC optimize(2)
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <bitset>
#include <cmath>
#include <cctype>
#include <iostream>
#include <unordered_map>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll inff = 0x3f3f3f3f3f3f3f3f;
#define FOR(i,a,b) for(int i(a);i<=(b);++i)
#define FOL(i,a,b) for(int i(a);i>=(b);--i)
#define REW(a,b) memset(a,b,sizeof(a))
#define inf int(0x3f3f3f3f)
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define pb push_back
#define mod ll(1e9+7)
#define lc (d<<1)
#define Pll pair<ll,ll>
#define P pair<int,int>
#define pi acos(-1)
const int N=1e5+8;
int n,dp[2][88][6408],x,qw,d[2][88][6408];
int num(int x){return x*(x-1)/2;}
int main()
{
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    REW(dp,inf);dp[0][0][0]=0;
    FOR(i,1,n)
    {
        cin>>x;
        if(!x) qw++;
        int zz=num(n);
        FOR(id,0,1)
         FOR(j,0,i)
          FOR(k,0,zz) d[id][j][k]=dp[id][j][k],dp[id][j][k]=inf;
        FOR(j,0,i)
         FOR(k,0,zz)
         {
             if(x&&d[0][j][k]!=inf)
             {
                 dp[1][j][k]=min(dp[1][j][k],d[0][j][k]);
                 FOR(kk,0,j) dp[0][kk][k+kk]=min(dp[0][kk][k+kk],d[0][j][k]-num(j)+num(kk)+num(j-kk));
                 continue;
             }
             dp[0][j+1][k]=min(dp[0][j+1][k],d[0][j][k]-num(j)+num(j+1));
             if(d[1][j][k]!=inf)
              FOR(kk,0,j)
              {
                  dp[0][0][k+1]=min(dp[0][0][k+1],d[1][j][k]-num(j)+num(j+1));
                  dp[1][j+1][k+1]=min(dp[1][j+1][k+1],d[1][j][k]-num(j)+num(j+1));
              }
         }
    }
    int zz=num(n),ds=0;
    FOR(i,0,zz)
    {
        int ans=num(qw),z=inf;
        FOR(j,0,n) z=min(z,dp[1][j][i]),z=min(z,dp[0][j][i]);
        ds=max(ds,ans-z);
        printf("%d ",ds);
    }
    puts("");
    return 0;
}


#pragma GCC optimize(2)
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <bitset>
#include <cmath>
#include <cctype>
#include <iostream>
#include <unordered_map>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll inff = 0x3f3f3f3f3f3f3f3f;
#define FOR(i,a,b) for(int i(a);i<=(b);++i)
#define FOL(i,a,b) for(int i(a);i>=(b);--i)
#define REW(a,b) memset(a,b,sizeof(a))
#define inf int(0x3f3f3f3f)
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define pb push_back
#define mod ll(1e9+7)
#define lc (d<<1)
#define Pll pair<ll,ll>
#define P pair<int,int>
#define pi acos(-1)
const int N=1e5+8;
int n,dp[88][88][88*88],x,qw,las;
int num(int x){return x*(x-1)/2;}
int main()
{
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    las=-1;
    REW(dp,inf),dp[0][0][0]=0;
    FOR(i,1,n)
    {
        cin>>x;
        if(!x) qw++;
        else las=i-1;
        int zz=num(n);
        FOR(j,0,i)
         FOR(k,0,zz)
          if(dp[i-1][j][k]!=inf)
          {
              if(!x)
              {
                dp[i][j+1][k]=min(dp[i][j+1][k],dp[i-1][j][k]-num(j)+num(j+1));
                FOR(kk,0,las)
                 if(dp[las][kk][k]!=inf) dp[i][0][k+i-las-1]=min(dp[i][0][k+i-las-1],dp[las][kk][k]-num(kk)+num(kk+i-las-1));
                continue;
              }
              FOR(kk,0,j)
               dp[i][kk][k+kk]=min(dp[i][kk][k+kk],dp[i-1][j][k]-num(j)+num(kk)+num(j-kk));
          }
    }
    int zz=num(n),ds=0;
    FOR(i,0,zz)
    {
        int ans=num(qw),z=inf;
        FOR(j,0,n) z=min(z,dp[n][j][i]);
        ans-=z;
        ds=max(ds,ans);
        printf("%d ",ds);
    }
    puts("");
    return 0;
}


#pragma GCC optimize(2)
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <bitset>
#include <cmath>
#include <cctype>
#include <iostream>
#include <unordered_map>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll inff = 0x3f3f3f3f3f3f3f3f;
#define FOR(i,a,b) for(int i(a);i<=(b);++i)
#define FOL(i,a,b) for(int i(a);i>=(b);--i)
#define REW(a,b) memset(a,b,sizeof(a))
#define inf int(0x3f3f3f3f)
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define pb push_back
#define mod ll(1e9+7)
#define lc (d<<1)
#define Pll pair<ll,ll>
#define P pair<int,int>
#define pi acos(-1)
const int N=1e5+8;
int n,dp[88][88][88*88],x,qw,las;
int num(int x){return x*(x-1)/2;}
int main()
{
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    las=-1;
    REW(dp,inf);
    FOR(i,0,num(n)) dp[0][0][i]=0;
    FOR(i,1,n)
    {
        cin>>x;
        if(!x) qw++;
        else las=i-1;
        int zz=num(n);
        FOR(j,0,i)
         FOR(k,0,zz)
          if(dp[i-1][j][k]!=inf)
          {
              if(!x) {dp[i][j+1][k]=min(dp[i][j+1][k],dp[i-1][j][k]-num(j)+num(j+1));continue;}
              FOR(kk,0,j)
               dp[i][kk][k+kk]=min(dp[i][kk][k+kk],dp[i-1][j][k]-num(j)+num(kk)+num(j-kk));
          }
        if(!x)
         FOR(k,0,zz)
          FOR(kk,0,las)
           if(dp[las][kk][k]!=inf) dp[i][0][k+i-las-1]=min(dp[i][0][k+i-las-1],dp[las][kk][k]-num(kk)+num(kk+i-las-1));
    }
    int zz=num(n);
    FOR(i,0,zz)
    {
        int ans=num(qw),z=inf;
        FOR(j,0,n) z=min(z,dp[n][j][i]);
        ans-=z;
        printf("%d ",ans);
    }
    puts("");
    return 0;
}


#pragma GCC optimize(2)
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <bitset>
#include <cmath>
#include <cctype>
#include <iostream>
#include <unordered_map>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll inff = 0x3f3f3f3f3f3f3f3f;
#define FOR(i,a,b) for(int i(a);i<=(b);++i)
#define FOL(i,a,b) for(int i(a);i>=(b);--i)
#define REW(a,b) memset(a,b,sizeof(a))
#define inf int(0x3f3f3f3f)
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define pb push_back
#define mod ll(1e9+7)
#define lc (d<<1)
#define Pll pair<ll,ll>
#define P pair<int,int>
#define pi acos(-1)
const int N=1e5+8;
int n,dp[88][88][88*88],x,qw,las;
int num(int x){return x*(x-1)/2;}
int main()
{
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    las=-1;
    REW(dp,inf);
    FOR(i,0,num(n)) dp[0][0][i]=0;
    FOR(i,1,n)
    {
        cin>>x;
        if(!x) qw++;
        else las=i-1;
        int zz=num(n);
        FOR(j,0,i)
         FOR(k,0,zz)
          if(dp[i-1][j][k]!=inf)
          {
              if(!x)
              {
                dp[i][j+1][k]=min(dp[i][j+1][k],dp[i-1][j][k]-num(j)+num(j+1));
                FOR(kk,0,las)
                 if(dp[las][kk][k]!=inf) dp[i][0][k+i-las-1]=min(dp[i][0][k+i-las-1],dp[las][kk][k]-num(kk)+num(kk+i-las-1));
                continue;
              }
              FOR(kk,0,j)
               dp[i][kk][k+kk]=min(dp[i][kk][k+kk],dp[i-1][j][k]-num(j)+num(kk)+num(j-kk));
          }
    }
    int zz=num(n);
    FOR(i,0,zz)
    {
        int ans=num(qw),z=inf;
        FOR(j,0,n) z=min(z,dp[n][j][i]);
        ans-=z;
        printf("%d ",ans);
    }
    puts("");
    return 0;
}


#pragma GCC optimize(2)
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <bitset>
#include <cmath>
#include <cctype>
#include <iostream>
#include <unordered_map>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll inff = 0x3f3f3f3f3f3f3f3f;
#define FOR(i,a,b) for(int i(a);i<=(b);++i)
#define FOL(i,a,b) for(int i(a);i>=(b);--i)
#define REW(a,b) memset(a,b,sizeof(a))
#define inf int(0x3f3f3f3f)
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define pb push_back
#define mod ll(1e9+7)
#define lc (d<<1)
#define Pll pair<ll,ll>
#define P pair<int,int>
#define pi acos(-1)
const int N=1e5+8;
int n,dp[88][6408],x,qw,d[88][6408];
vector<int>g;
int num(int x){return x*(x-1)/2;}
int main()
{
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    g.pb(0);
    FOR(i,1,n)
    {
        cin>>x;
        if(x) g.pb(i);
        else qw++;
    }
    g.pb(n+1);
    int zz=num(n);
    REW(dp,-1),dp[0][0]=0;
    FOR(i,1,n-qw+1)
    {
        FOR(j,0,qw)
         FOR(k,0,zz) d[j][k]=dp[j][k],dp[j][k]=-1;
        FOR(j,0,qw)
         FOR(k,0,zz)
         {
             if(d[j][k]>=0)
              FOR(kk,0,qw-j)
               dp[j+kk][k+abs(i+j+kk-g[i])]=max(dp[j+kk][k+abs(i+j+kk -g[i])],d[j][k]+j*kk);
         }
    }
    int ans=0;
    FOR(i,0,zz) ans=max(dp[qw][i],ans),printf("%d ",ans);
    puts("");
    return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define fst first
#define snd second
#define rep(i, st, ed) for(int i=st; i<(int)ed; i++)
#define repn(i, st, ed) for(int i=st; i<=(int)ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=(int)st; i--)
#define trav(x, v) for(auto &x: v)
#define all(v) v.begin(), v.end()
#define mp make_pair
#define pb push_back
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define RANDOM_GEN(st, ed)  uniform_int_distribution<int>(st, ed)(rng)
#define sz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define popb pop_back

using ll = long long;
using ld = long double;

using pi = pair<int,int>;
using pl = pair<ll, ll>;
using pd = pair<ld, ld>;

using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<ld>;
using vpi = vector<pi>;

const int N = 2e5 + 10;
const int M = 1e9 + 7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

template <class T> using oset = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using maxpq = priority_queue<T>;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << to_string(H) << endl;
  debug_out(T...);
}
#define LOCAL 3
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:" << endl, debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

unordered_map<bitset<80>, ll> dp;

int n;
int total;
ll ans[N];
ll mans = 0;

ll findans(bitset<80> z){
	ll tans = 0;
	int cnt = 0;
	vi tmp;
	int sum = 0;
	rep(i, 0, n){
		if(z[i]) {
			if(cnt == 0) continue;
			sum += cnt; tmp.pb(cnt); cnt = 0;
			}
		else cnt++;
	}
	if(cnt ) {
		tmp.pb(cnt);
		sum += cnt;
	}
	//debug(tmp);
	rep(i, 0, sz(tmp)){
		sum = sum - tmp[i];
		tans += 1ll * sum * tmp[i];
	}
	return tans;
}

void calans(bitset<80> z, int depth){
	if(depth > total) return;
	if(dp.count(z)) {ans[depth] = max(ans[depth], dp[z]); return;}
	dp[z] = findans(z);
	ans[depth] = max(ans[depth], dp[z]);
	//debug(z);
	rep(i, 1, n){
		if(z[i] && !z[i-1]){
			z[i] = 0, z[i-1] = 1;
			calans(z, depth+1);
			z[i] = 1, z[i-1] = 0;
		}
	}
	rep(i, 0, n-1){
		if(z[i] && !z[i+1]){
			z[i] = 0, z[i+1] = 1;
			calans(z, depth+1);
			z[i] = 1, z[i+1] = 0;
		}
	}
}

void solve()
{
	cin >> n;
	total = (n*(n-1)) / 2;
	int x;
	bitset<80> cur;
	rep(i, 0, n){
		cin >> x;
		cur[i] = x;
	}
	ans[0] = findans(cur);
	mans = ans[0];
	calans(cur, 0);
	repn(i, 0, total){
		mans = max(mans, ans[i]);
		cout << mans << " ";
	}
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cout << fixed;
	cout << setprecision(12);

	// Write code before test cases

	// solving test cases

	int tests = 1;
	//cin >> tests;
	while(tests--) solve();

#ifndef ONLINE_JUDGE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define fst first
#define snd second
#define rep(i, st, ed) for(int i=st; i<(int)ed; i++)
#define repn(i, st, ed) for(int i=st; i<=(int)ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=(int)st; i--)
#define trav(x, v) for(auto &x: v)
#define all(v) v.begin(), v.end()
#define mp make_pair
#define pb push_back
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define RANDOM_GEN(st, ed)  uniform_int_distribution<int>(st, ed)(rng)
#define sz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define popb pop_back

using ll = long long;
using ld = long double;

using pi = pair<int,int>;
using pl = pair<ll, ll>;
using pd = pair<ld, ld>;

using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<ld>;
using vpi = vector<pi>;

const int N = 2e5 + 10;
const int M = 1e9 + 7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

template <class T> using oset = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using maxpq = priority_queue<T>;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << to_string(H) << endl;
  debug_out(T...);
}
#define LOCAL 3
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:" << endl, debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

unordered_map<bitset<80>, ll> dp[N];

int n;
int total;
ll ans[N];
ll mans = 0;

ll findans(bitset<80> z){
	ll tans = 0;
	int cnt = 0;
	vi tmp;
	int sum = 0;
	rep(i, 0, n){
		if(z[i]) {
			if(cnt == 0) continue;
			sum += cnt; tmp.pb(cnt); cnt = 0;
			}
		else cnt++;
	}
	if(cnt ) {
		tmp.pb(cnt);
		sum += cnt;
	}
	//debug(tmp);
	rep(i, 0, sz(tmp)){
		sum = sum - tmp[i];
		tans += 1ll * sum * tmp[i];
	}
	return tans;
}

void calans(bitset<80> z, int depth){
	if(depth > total) return;
	if(dp[depth].count(z)) {ans[depth] = max(ans[depth], dp[depth][z]); return;}
	dp[depth][z] = findans(z);
	ans[depth] = max(ans[depth], dp[depth][z]);
	//debug(z);
	rep(i, 1, n){
		if(z[i] && !z[i-1]){
			z[i] = 0, z[i-1] = 1;
			calans(z, depth+1);
			z[i] = 1, z[i-1] = 0;
		}
	}
	rep(i, 0, n-1){
		if(z[i] && !z[i+1]){
			z[i] = 0, z[i+1] = 1;
			calans(z, depth+1);
			z[i] = 1, z[i+1] = 0;
		}
	}
}

void solve()
{
	cin >> n;
	total = (n*(n-1)) / 2;
	int x;
	bitset<80> cur;
	rep(i, 0, n){
		cin >> x;
		cur[i] = x;
	}
	ans[0] = findans(cur);
	mans = ans[0];
	calans(cur, 0);
	repn(i, 0, total){
		mans = max(mans, ans[i]);
		cout << mans << " ";
	}
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cout << fixed;
	cout << setprecision(12);

	// Write code before test cases

	// solving test cases

	int tests = 1;
	//cin >> tests;
	while(tests--) solve();

#ifndef ONLINE_JUDGE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define fst first
#define snd second
#define rep(i, st, ed) for(int i=st; i<(int)ed; i++)
#define repn(i, st, ed) for(int i=st; i<=(int)ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=(int)st; i--)
#define trav(x, v) for(auto &x: v)
#define all(v) v.begin(), v.end()
#define mp make_pair
#define pb push_back
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define RANDOM_GEN(st, ed)  uniform_int_distribution<int>(st, ed)(rng)
#define sz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define popb pop_back

using ll = long long;
using ld = long double;

using pi = pair<int,int>;
using pl = pair<ll, ll>;
using pd = pair<ld, ld>;

using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<ld>;
using vpi = vector<pi>;

const int N = 2e5 + 10;
const int M = 1e9 + 7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

template <class T> using oset = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using maxpq = priority_queue<T>;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << to_string(H) << endl;
  debug_out(T...);
}
#define LOCAL 3
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:" << endl, debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int dp[85][85][6410];

void solve()
{
	int n;
	cin >> n;
	vi v(n);
	rep(i, 0, n) cin >> v[i];
	vi cur;
	int cnt = 0;
	rep(i ,0 ,n){
		if(v[i]) {cur.pb(cnt); cnt = 0;}
		else cnt++;
	}
	cur.pb(cnt);
	int sum = 0;
	sum = accumulate(all(cur), sum);
	partial_sum(cur.begin(), cur.end(), cur.begin());
	int moves = (n*(n-1)) / 2;
	n = sz(cur);
	//debug(cur, sum);
	memset(dp, 0x3f, sizeof(dp));
	dp[0][0][0] = 0;
	rep(i, 0, n){
		repn(j, 0, sum){
			repn(k, 0, moves){
				if(dp[i][j][k] == infi) continue;
				repn(q, j, sum){
					chmin(dp[i+1][q][k+abs(q-cur[i])], dp[i][j][k] + (q-j)*(q-j));
				}
			}
		}
	}
	int mn = infi;
	repn(i, 0, moves){
		chmin(mn, dp[n][sum][i]);
		//cout << dp[n][sum][i] << " ";
		int ans = sum*sum -  mn;
		assert(ans%2 == 0);
		cout << ans/2 << " ";
	}
	cout << endl;
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cout << fixed;
	cout << setprecision(12);

	// Write code before test cases

	// solving test cases

	int tests = 1;
	//cin >> tests;
	while(tests--) solve();

#ifndef ONLINE_JUDGE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define fst first
#define snd second
#define rep(i, st, ed) for(int i=st; i<(int)ed; i++)
#define repn(i, st, ed) for(int i=st; i<=(int)ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=(int)st; i--)
#define trav(x, v) for(auto &x: v)
#define all(v) v.begin(), v.end()
#define mp make_pair
#define pb push_back
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define RANDOM_GEN(st, ed)  uniform_int_distribution<int>(st, ed)(rng)
#define sz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define popb pop_back

using ll = long long;
using ld = long double;

using pi = pair<int,int>;
using pl = pair<ll, ll>;
using pd = pair<ld, ld>;

using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<ld>;
using vpi = vector<pi>;

const int N = 2e5 + 10;
const int M = 1e9 + 7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

template <class T> using oset = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using maxpq = priority_queue<T>;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << to_string(H) << endl;
  debug_out(T...);
}
#define LOCAL 3
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:" << endl, debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

unordered_map<bitset<80>, ll> dp[N];
unordered_map<bitset<80>, ll> stans;

int n;
int total;
ll ans[N];
ll mans = 0;

ll findans(bitset<80> z){
	if(stans.count(z)) return stans[z];
	ll tans = 0;
	int cnt = 0;
	vi tmp;
	int sum = 0;
	rep(i, 0, n){
		if(z[i]) {
			if(cnt == 0) continue;
			sum += cnt; tmp.pb(cnt); cnt = 0;
			}
		else cnt++;
	}
	if(cnt ) {
		tmp.pb(cnt);
		sum += cnt;
	}
	//debug(tmp);
	rep(i, 0, sz(tmp)){
		sum = sum - tmp[i];
		tans += 1ll * sum * tmp[i];
	}
	return stans[z] = tans;
}

void calans(bitset<80> z, int depth){
	if(depth > total) return;
	if(dp[depth].count(z)) {ans[depth] = max(ans[depth], dp[depth][z]); return;}
	dp[depth][z] = findans(z);
	ans[depth] = max(ans[depth], dp[depth][z]);
	//debug(z);
	rep(i, 1, n){
		if(z[i] && !z[i-1]){
			z[i] = 0, z[i-1] = 1;
			calans(z, depth+1);
			z[i] = 1, z[i-1] = 0;
		}
	}
	rep(i, 0, n-1){
		if(z[i] && !z[i+1]){
			z[i] = 0, z[i+1] = 1;
			calans(z, depth+1);
			z[i] = 1, z[i+1] = 0;
		}
	}
}

void solve()
{
	cin >> n;
	total = (n*(n-1)) / 2;
	int x;
	bitset<80> cur;
	rep(i, 0, n){
		cin >> x;
		cur[i] = x;
	}
	ans[0] = findans(cur);
	mans = ans[0];
	calans(cur, 0);
	repn(i, 0, total){
		mans = max(mans, ans[i]);
		cout << mans << " ";
	}
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cout << fixed;
	cout << setprecision(12);

	// Write code before test cases

	// solving test cases

	int tests = 1;
	//cin >> tests;
	while(tests--) solve();

#ifndef ONLINE_JUDGE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


// practice with Dukkha, coached by rainboy
#pragma GCC optimize("O3")
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 80, M = N * (N - 1) / 2, INF = 0x3f3f3f3f;

int ii[N + 2];
int dp[M + 1][N + 2], dq[M + 1][N + 2];

int main() {
	int n; cin >> n;
	int m = n * (n - 1) / 2;
	int k = 0;
	for (int i = 1; i <= n; i++) {
		int a; cin >> a;
		if (a == 1)
			ii[++k] = i;
	}
	ii[k + 1] = n + 1;
	for (int d = 0; d <= m; d++)
		for (int i = 0; i <= n + 1; i++)
			dp[d][i] = INF;
	dp[0][0] = 0;
	for (int h = 1; h <= k + 1; h++) {
		for (int u = 0; u <= m; u++)
			for (int i = 0; i <= n + 1; i++) {
				int x = INF;
				int v = u - abs(i - ii[h]);
				if (v >= 0)
					for (int g = 0, j; (j = i - g - 1) >= 0; g++)
						x = min(x, dp[v][j] + g * (g - 1));
				dq[u][i] = x;
			}
		for (int u = 0; u <= m; u++)
			for (int i = 0; i <= n + 1; i++)
				dp[u][i] = dq[u][i];
	}
	int x = INF;
	int y = (n - k) * (n - k - 1);
	for (int u = 0; u <= m; u++) {
		x = min(x, dp[u][n + 1]);
		cout << (y - x) / 2 << ' ';
	}
	cout << '\n';
	return 0;
}


// practice with Dukkha, coached by rainboy
#pragma GCC optimize("O3")
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 80, M = N * (N - 1) / 2, INF = 0x3f3f3f3f;

int ii[N + 2], dp[M + 1][N + 2], dq[M + 1][N + 2];

int main() {
	int n; cin >> n;
	int m = n * (n - 1) / 2;
	int k = 0;
	for (int i = 1; i <= n; i++) {
		int a; cin >> a;
		if (a == 1)
			ii[++k] = i;
	}
	ii[k + 1] = n + 1;
	for (int d = 0; d <= m; d++)
		for (int i = 0; i <= n + 1; i++)
			dp[d][i] = INF;
	dp[0][0] = 0;
	for (int h = 1; h <= k + 1; h++) {
		for (int u = 0; u <= m; u++)
			for (int i = 0; i <= n + 1; i++) {
				int x = INF;
				int v = u - abs(i - ii[h]);
				if (v >= 0)
					for (int g = 0, j; (j = i - g - 1) >= 0; g++)
						x = min(x, dp[v][j] + g * (g - 1) / 2);
				dq[u][i] = x;
			}
		for (int u = 0; u <= m; u++)
			for (int i = 0; i <= n + 1; i++)
				dp[u][i] = dq[u][i];
	}
	int x = INF;
	int y = (n - k) * (n - k - 1) / 2;
	for (int u = 0; u <= m; u++) {
		x = min(x, dp[u][n + 1]);
		cout << y - x << ' ';
	}
	cout << '\n';
	return 0;
}


// practice with Dukkha, coached by rainboy
#pragma GCC optimize("O3")
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 80, M = N * (N - 1) / 2, INF = 0x3f3f;

int ii[N + 2];
short dp[M + 1][N + 2], dq[M + 1][N + 2];

int main() {
	int n; cin >> n;
	int m = n * (n - 1) / 2;
	int k = 0;
	for (int i = 1; i <= n; i++) {
		int a; cin >> a;
		if (a == 1)
			ii[++k] = i;
	}
	ii[k + 1] = n + 1;
	for (int d = 0; d <= m; d++)
		for (int i = 0; i <= n + 1; i++)
			dp[d][i] = INF;
	dp[0][0] = 0;
	for (int h = 1; h <= k + 1; h++) {
		for (int u = 0; u <= m; u++)
			for (int i = 0; i <= n + 1; i++) {
				short x = INF;
				short v = u - abs(i - ii[h]);
				if (v >= 0)
					for (int g = 0, j; (j = i - g - 1) >= 0; g++)
						x = min(x, (short) (dp[v][j] + g * (g - 1) / 2));
				dq[u][i] = x;
			}
		for (int u = 0; u <= m; u++)
			for (int i = 0; i <= n + 1; i++)
				dp[u][i] = dq[u][i];
	}
	short x = INF;
	int y = (n - k) * (n - k - 1) / 2;
	for (int u = 0; u <= m; u++) {
		x = min(x, dp[u][n + 1]);
		cout << y - x << ' ';
	}
	cout << '\n';
	return 0;
}