#include<stdio.h>

int main(){
  int n,a[210000],count=0;
  int i,j;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&a[i]);
  a[n] = -1;
  i=0;
  j=i+1;
  
  while(a[i]!=-1){
    if(a[j]==-1){
      i++;
      j=i;
    }
    if(a[i]>a[j]) count++;
    j++;
  }
  
  printf("%d\n",count);
  
  return 0;
}

