LearnPy Hub
← Arena
IntermediateRating 1300

Jump to a Zero

You stand at index s (from 0). From index i you may jump to i + a[i] or i − a[i], staying inside the list. Can you reach any index holding 0? Print YES or NO.

Input

n and s, then n non-negative integers.

Output

YES or NO.

Sample 1

Input
7 5
4 2 3 0 3 1 2
Output
YES

Sample 2

Input
7 0
4 2 3 0 3 1 2
Output
YES
solution.py
Output appears here
Jump to a Zero · Python Arena problem · LearnPy Hub