var a:array[1..100000] of longint ;
      n,i,ans,j:longint ;
procedure swap(n,m:longint) ;
var t:longint ;
begin 
   a[n]:=t ;a[n]:=a[m];a[m]:=t ;
end;
begin 
   readln(n) ;
	 for i:=1 to n do read(a[i]) ;
	 for i:=1 to n do 
	 begin 
	   if a[i]<>i then continue ;
		 if i=1 then swap(1,2) 
		 else if i=n then 
		 begin
			 swap(n,n-1) ;
			 j:=a[n-1] ;
			 while (j>1) and (a[j]=j) do 
			 begin 
			   if a[j-1]=j then swap(j,j+1)
				 else swap(j,j-1); 
				 inc(ans) ;
			 end;
		 end
		 else if a[i-1]=i then swap(i,i+1)
		 else swap(i,i-1) ;
		 inc(ans) ;
	 end;
	 writeln(ans) ;
end.