This page is still under construction.

Parts of this page are still being built. What you see may change.

Greedy Gift Takers

Time limit2sMemory limit512 MB

Summary
Each cow takes a gift and reinserts herself c_i positions from the tail; count how many cows never reach the head.
Level

Hard8 of 10

Topics
Math, Simulation
Solved
No attempts yet

Problem

Farmer John's rival, Farmer Nhoj, keeps NN cows (1≤N≤1051 \leq N \leq 10^5) numbered 11 through NN. They have turned up at Farmer John's farm without warning, and Farmer John, always polite, decides to hand each of them a gift.

Farmer John has an unlimited supply of gifts. Nhoj's cows line up in front of him, cow 11 at the head of the line and cow NN at the tail. Farmer John expected that at every timestep the cow at the head would take a gift and walk to the tail. Nhoj's cows are not that polite. After taking her gift, a cow does not go to the tail: she cuts in front of some of the cows near the tail. To be exact, cow ii always cuts exactly cic_i cows (0≤ci≤N−10 \leq c_i \leq N-1). The line always holds NN cows, so right after taking a gift cow ii stands at position N−ciN - c_i counted from the head.

Since the supply is unlimited, Farmer John does not mind that some cows take several gifts. He does worry that some cows may take none at all.

Find how many cows never receive a gift, no matter how long the gifts are handed out.

Input

The first line contains one integer NN.

The second line contains the integers c1,c2,…,cNc_1, c_2, \dots, c_N separated by spaces.

Output

Print the number of cows that never receive a gift.

Examples1

  1. Example 1

    Input
    3
    1 2 0
    
    Expected output
    1