io = STDIN
n=io.gets.to_i
$a=io.gets.split.map(&:to_i)
def check(i)
  if $a[i]==i+1 &&
    $a[i+1]==i+2
    $a[i+1],$a[i]=$a[i],$a[i+1]
    $ans+=1
    return true
  else
    return false
  end
end
$ans=0
top=0
lst=n-1
turn=:top
while top+1<lst-1
  if turn == :top
    if check(top)
      turn = :lst
    else
      top+=1
    end
  else
    if check(lst-1)
      turn = :top
    else
      lst-=1
    end
  end
end
$a.each_with_index do |x,i|
  if x==i+1
    $ans+=1
  end
end
puts $ans
