#include <iostream>
using namespace std;
const int N = 1005;
int n;
int a[N];
int f[N][N];
int ans;
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
for(int i=1;i<=n;i++){
for(int d=1;d<=i;d++){
f[i][d] = 1;
if(a[i] >= a[i - d]){
f[i][d] = f[i - d][d] + 1;
}
ans = max(ans,f[i][d]);
}
}
printf("%d",n - ans);
return 0;
}