#include using namespace std; const int INF = 1000000000; int main(){ int N; cin >> N; vector P(N); for (int i = 0; i < N; i++){ cin >> P[i]; P[i]--; } vector> S(N + 1, vector(N + 1, 0)); for (int i = 0; i < N; i++){ for (int j = i + 1; j < N; j++){ if (P[i] > P[j]){ S[i][j + 1]++; } } } for (int i = 0; i <= N; i++){ for (int j = 0; j < N; j++){ S[i][j + 1] += S[i][j]; } } for (int i = N; i >= 1; i--){ for (int j = 0; j <= N; j++){ S[i - 1][j] += S[i][j]; } } vector mx(N + 1, 0); for (int i = 0; i <= N; i++){ for (int j = i; j <= N; j++){ mx[j - i] = max(mx[j - i], S[i][j]); S[i][j] *= -1; } } vector> dp(N + 1, vector(N + 1, INF)); dp[0][0] = 0; for (int i = 0; i < N; i++){ for (int j = i; j < N; j++){ for (int k = j + 1; k <= N; k++){ dp[i + 1][k] = min(dp[i + 1][k], dp[i][j] + S[j][k]); } } } for (int i = 1; i <= N; i++){ cout << -S[0][N] + dp[i][N] << endl; } }