Building Blocks

No attempts yetTime limit1sMemory limit128 MB

Problem

Little Jessica received a set of building blocks for her birthday. The blocks are all cubes of the same size, and each block has a positive integer written on it. Delighted with the gift, she immediately stacked every block into one tall tower.

Her mother explained the game: reshape the tower so that as many blocks as possible sit in their proper place. A block with the number ii written on it is in its proper place when it rests at altitude ii. The bottom block is at altitude 11, the block above it at altitude 22, and so on.

Jessica may carefully remove some of the blocks. Whenever a block is removed, every block above it slides down by one, and the altitudes are renumbered from the bottom. She wants to remove blocks so that the number of blocks left in their proper place is as large as possible.

Given the tower Jessica first built, determine the largest number of blocks that can end up in their proper place.

Input

The first line contains a single integer nn (1n1000001 \le n \le 100000), the initial height of the tower. The second line contains nn positive integers a1,a2,,ana_1, a_2, \ldots, a_n (1ai10000001 \le a_i \le 1000000), separated by single spaces, where aia_i is the number written on the block at altitude ii in the initial tower, listed from the lowest block to the highest.

Output

Print a single integer: the maximum number of blocks that can be in their proper place after Jessica removes some blocks.

Hint