N = gets.to_i
Ps = gets.split.map(&:to_i)

def match(ost, ary)
  (1 .. ary.size).find{|n| n + ost == ary[n - 1]} || false
end

def swap(acc, ost, ary)
  p [acc, ost, ary]
  case m = match(ost, ary)
  when false
    acc
  when m + ost == N
    acc + 1
  else
    swap(acc + 1, m + ost + 1, ary[m + 1 .. -1])
  end
end

puts swap(0, 0, Ps)