U77570 「USACO 2017.12 Platinum」 Greedy Gift Takers

题目背景

奶牛们领礼物啦!

题目描述

Farmer John's nemesis, Farmer Nhoj, has NN cows (1 \leq N \leq 10^51≤N≤105 ), conveniently numbered 1 \dots N1…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 11 at the head of the queue and cow NN 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 ii will always cut exactly c_ici cows (0 \leq c_i \leq N-10≤ci​≤N−1 ). 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. N头奶牛排成一列,准备领礼物。此时,奶牛们依次编号为1...N 。农夫约翰站在队头发礼物。 奶牛i 的权值为Ci,每个到达队头的牛拿到礼物后会插队,插进倒数第Ci+1的位置。现在我们想知道,有多少奶牛不可能领到礼物。

输入格式

第一行一个数表示N; 第二行 N 个数表示 C1,C2,...,Cn。

输出格式

一行一个数表示答案。

说明/提示

对于全部数据,1