#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+10;
long s[maxn],top=1;
long ans=0;
int main(){
long n;
cin>>n;
cin>>s[1];
for(int i=2;i<=n;++i){
long k;
bool flag=0;
cin>>k;
if(k<s[top]) ans++;
while(k>=s[top]&&top){
top--;
flag=true;
}
s[++top]=k;
if(flag&&top) ans++;
}
cout<<ans;
return 0;
本地和点一过了