using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); public static void Main() { Solve(); } static void Solve() { var n = NN; var a = NList; var cum = new int[n - 1]; cum[0] = a[0]; for (var i = 1; i < a.Length; ++i) cum[i] = Math.Max(cum[i - 1], a[i]); var max = 1; var ans = 0; while (max < n) { max = cum[max - 1]; ++ans; } WriteLine(ans); } }