eolymp
bolt
Try our new interface for solving problems
Problems

Greedy Gift Takers

Greedy Gift Takers

Farmer John's nemesis, Farmer Nhoj, has n cows, conveniently numbered 1 .. n. They have unexpectedly turned up at Farmer John's farm, so the unfailingly polite Farmer John is attempting to give them gifts.

To this end, Farmer John has brought out his infinite supply of gifts, and Nhoj's cows have queued up in front of him, with cow 1 at the head of the queue and cow n at the tail. Farmer John was expecting that at every timestep, the cow at the head of the queue would take a gift from Farmer John and go to the tail of the queue. However, he has just realized that Nhoj's cows are not that polite! After receiving her gift, each cow may not go to the tail of the queue, but rather may cut some number of cows at the tail, and insert herself in front of them. Specifically, cow i will always cut exactly ci cows.

Farmer John knows that some cows might receive multiple gifts; as he has an infinite supply, this does not worry him. But he is worried that some cows might become unhappy if they do not get any gifts.

Help Farmer John find the number of cows who never receive any gifts, no matter how many gifts are handed out.

Input

The first line contains a single integer n (1n105). The second line contains n integers c1, c2, .., cn (0cin1).

Output

Please output the number of cows who cannot receive any gifts.

Time limit 1 second
Memory limit 128 MiB
Input example #1
3
1 2 0
Output example #1
1
Source 2017 USACO December, Platinum