#!/usr/bin/env python3 def main(): N = int(input()) R = list(map(lambda i: int(i) - 1, input().split())) + [N - 1] now = 0 next = 0 temp = 0 for i in range(R[0] + 1): if R[i] >= temp: next = i temp = R[i] ans = 0 while now < N - 1: checked = now now = next temp = 0 for i in range(checked + 1, R[next] + 1): if R[i] >= temp: next = i temp = R[i] ans += 1 print(ans) if __name__ == '__main__': main()