https://www.acwing.com/problem/content/484/
#include<bits/stdc++.h>
using namespace std;
const int N=110;
int h[N];
int on[N],under[N];
int n;
int ans;
int main(){
cin>>n;
for(int i=1;i<=n;i++){
scanf("%d",&h[i]);
}
for(int i=1;i<=n;i++){
on[i]=1;
// under[i]=1;
for(int j=1;j<i;j++){
if(h[i]>h[j]){
on[i]=max(on[j]+1,on[i]);
}
}
}
for(int i=n;i>=1;i--){
under[i]=1;
for(int j=n;j>i;j--){
if(h[i]>h[j]){
under[i]=max(under[j]+1,under[i]);
}
// else under[i]=under[i+1];
}
ans=max(on[i]+under[i]-1,ans);
}
printf("%d\n",n-ans);
return 0;
}