#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]); } } for (int i = 1; i <= N; i++){ cout << S[0][N] - mx[N + 1 -i] << endl; } }