domine
In our little city Abensibeu people have different habits and traditions from the rest of the country. In this little city, people are playing dominoes with a bunch of dominos that are of different sizes. On some of the dominos there are up to 200 numbers, sorted in rows. On some of them there is just one number. Jovica and Perica bought this strange set of dominoes but there weren't instructions in the box. And because they aren't from Abensibeu, they don't know how to play with dominos that are different sizes. So, they decided set up the dominoes in a row, which falls down when you push the first domino. After a few days of setting up, they joined a long string of dominoes, with equally spaced dominoes. However, they don't know how many dominos will fall if they push the first one. And because they worked really hard to set it up, they don't want to destroy it and then count the dominoes that fell.
That's why you need to help them count the number of dominoes that will fall.
input:
6
2
3
1
2
1
1
output:
5
Explanation:
The first domino pushes down the second, the second pushes down the third and the fourth, the fourth pushes down the fifth, and the sixth one remains upright.
Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.