#include using namespace std; using ll=long long; using ull=unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) int N; vector I; vector F; int main(){ scanf("%d",&N); I.resize(N); rep(i,N){ int a; scanf("%d",&a); I[a-1]=i; } F.assign(N+1,0); int ans=0; rep(i,N){ if(F[I[i]+1]) continue; F[I[i]]=1; ans++; } printf("%d\n",ans); return 0; }