#include<bits/stdc++.h>
using namespace std;

int main()
{
 	int n;
  	cin>>n;
	int arr[n];
  	for(int i=0;i<n;i++)
      cin>>arr[i];
    int adjcount=0;
  	int sincount=0;
  	int prevadj=-1;
  	int prev=0;
  	int curr=0,next=1;
  	int i=0;
  	flag=0;
  	while(next<n){
    	if(curr==arr[curr])
        {
          	if(next==arr[next])
            {
              	adjcount+=2;
              	prevadj=next;
              	prev=next;
              	curr=curr+2;
              	next=next+2;
              	
            }
        }
      
      	if((prevadj==(curr-1)) && (prevadj!=-1) && (curr==arr[curr]))
        {
         	 adjcount+=1;
          	 prev=curr;
          	 curr++;	
          
        }
      	else if(curr==arr[curr])
        {
          	adjcount+=1
        }
    }
  
  
  
}
  