Under construction

Still being built. Things may change

Strange Grasshopper

Interview

Time limit2sMemory limit1024 MB

Summary
Starting at stone 1, the grasshopper jumps k stones from stone k across a row with destroyed stones. Decide whether it reaches the last stone.
Level

Easy2 of 10

Topics
Simulation, Implementation
Solved
No attempts yet

Problem

Let us set aside the topic of big dragons and turn to a small grasshopper that lives near the walls of a royal castle.

Like many grasshoppers, it likes to jump across the stones that form the castle walls. It has a favorite row of nn stones and a favorite way of jumping. If the grasshopper is on the kk-th stone of the row, it jumps exactly kk stones forward. For example, from the third stone it jumps to the sixth.

Once the grasshopper climbed onto the first stone of its row, it found that after a recent dragon attack some stones in the row were destroyed, and it cannot jump onto them.

Determine whether the destroyed stones prevent the grasshopper from reaching the last stone with its favorite jumps.

Input

The first line contains an integer nn (1≤n≤100001 \le n \le 10000), the number of stones in the grasshopper's favorite row. The second line contains nn integers aia_i separated by spaces. If stone ii was destroyed by the dragon, then aia_i is 00. Otherwise aia_i is 11.

The first and the last stones are not destroyed.

Output

Print Yes if the grasshopper can reach the last stone with its favorite jumps, and No otherwise.

Examples2

  1. Example 1

    Input
    4
    1 1 1 1
    
    Expected output
    Yes
    
  2. Example 2

    Input
    7
    1 0 1 0 1 1 1
    
    Expected output
    No