LearnPy Hub
← Arena
EasyRating 1000

Jumping on Clouds

Clouds are 0 (safe) or 1 (thunder). Starting on the first cloud, jump 1 or 2 clouds at a time, never landing on thunder. Print the fewest jumps to the last cloud.

Input

n, then n values (first and last are 0).

Output

One integer.

Sample 1

Input
7
0 0 1 0 0 1 0
Output
4

Sample 2

Input
6
0 0 0 0 1 0
Output
3
solution.py
Output appears here
Jumping on Clouds · Python Arena problem · LearnPy Hub