n = int(input()) r = list(map(int, input().split())) cur = 0 INF = 10 ** 9 ans = [INF] * n ans[0] = 0 for i in range(n - 1): while cur < r[i]: ans[cur] = min(ans[cur], ans[i] + 1) cur += 1 print(ans[-1])