#coding: utf-8 #yuki365 n=int(raw_input()) a=map(int,raw_input().split()) cnt=0 i=n-1 j=n-1 while i>=0: if a[i]=j+1: i-=1 j-=1 print cnt