n=int(input()) a=list(map(int,input().split())) b=[] for i in range(n): b.append((a[i],i)) b.sort() ans=0 pointer=0 if b[n-1][1]!=n-1: ans+=1 for i in range(n-2,-1,-1): if b[i][1]+1!=b[i+1][1]: if b[i+1][1]==pointer: pointer+=1 else: ans+=1 print(ans)