Sequence
题号:NC273397
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Alice has a sequence of length n, denoted as {a_1,a_2,...,a_n}.
Now, Alice can perform the following operations an infinite number of times:

1. First operation: Remove a number at a specific position. After removal, the subsequent numbers shift forward. For example, for the sequence {5, 1, 2, 3}, removing 1 will result in {5, 2, 3}.
2. Second operation: Insert a zero before a specific position. After insertion, the number at that position and the subsequent numbers shift backward. For example, for the sequence {5, 1, 2, 3}, inserting zero before 5 will result in {0, 5, 1, 2, 3}.

Now, Alice wants to maximize the number of positions in the sequence where a_i=i. Can you help Alice determine the maximum number of such positions?

输入描述:

One line containing a positive integer n, indicating the length of the sequence.
The next line contains n positive integers, representing each number in the sequence.

1 \le n \le 100,000, and 1 \le a_i \le 100,000

输出描述:

One line containing a positive integer, indicating the maximum number of numbers that can satisfy the condition in the sequence.
示例1

输入

复制
7
2 1 2 5 4 6 5

输出

复制
4