io = STDIN
n=io.gets.to_i
a=io.gets.split.map(&:to_i)
ans=0
a.each_cons(2).with_index(1) do |aa,i|
  #can't use aa
  if i!=n-1 && a[i-1]==i ||
     i==n-1 && a[i]==n
    a[i-1],a[i]=a[i],a[i-1]
    ans+=1
  end
end
puts ans
