#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MOD = 1e9 + 7;
void solve(){
int n;
cin >> n;
vector<int> a(n + 1);
for(int i = 1; i <= n; i++){
cin >> a[i];
}
vector<vector<int>> wrong(n + 1, vector<int>(n + 1, 0));
for(int i = 1; i <= n; i++){
int x = 1;
int cnt = 0;
for(int j = i + 2; j <= n; j++){
if(a[j - 1] != x){
cnt++;
}
x++;
wrong[i][j] = cnt;
}
}
vector<vector<int>> dp(n + 1, vector<int>(n + 1, INT_MAX / 10));
dp[0][0] = 0;
vector<int> ans(n + 1, n);
for(int j = 1; j <= n; j++){
for(int k = 2 - (j == 1); k <= j; k++){
for(int l = j - 1; l >= 0; l--){
dp[j][k] = min(dp[j][k], dp[l][k - 1] + wrong[l][j] + (a[j] != 0));
}
int x = 1;
int cnt = 0;
for(int l = j + 1; l <= n; l++){
if(a[l] != x)cnt++;
x++;
}
ans[k] = min(ans[k], dp[j][k] + cnt);
}
}
for(int i = 1; i <= n;i++){
cout << ans[i] << "\n";
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
freopen("taming.in", "r", stdin);
freopen("taming.out", "w", stdout);
int t = 1;
// cin >> t;
for(int i = 1; i <= t; i++){
solve();
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgbGwgbG9uZyBsb25nCgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IE1PRCA9IDFlOSArIDc7Cgp2b2lkIHNvbHZlKCl7CglpbnQgbjsKCWNpbiA+PiBuOwoJdmVjdG9yPGludD4gYShuICsgMSk7CgkKCWZvcihpbnQgaSA9IDE7IGkgPD0gbjsgaSsrKXsKCQljaW4gPj4gYVtpXTsKCX0KCQoJdmVjdG9yPHZlY3RvcjxpbnQ+PiB3cm9uZyhuICsgMSwgdmVjdG9yPGludD4obiArIDEsIDApKTsKCQoJZm9yKGludCBpID0gMTsgaSA8PSBuOyBpKyspewoJCWludCB4ID0gMT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