New Year is coming in Line World! In this world, there are n cells numbered by integers from 1 to n, as a 1 × n board. People live in cells. However, it was hard to move between distinct cells, because of the difficulty of escaping the cell. People wanted to meet people who live in other cells.

So, user tncks0121 has made a transportation system to move between these cells, to celebrate the New Year. First, he thought of n - 1 positive integers a_1, a_2, ..., a_{n} - 1. For every integer i where 1 ≤ i ≤ n - 1 the condition 1 ≤ a_{i} ≤ n - i holds. Next, he made n - 1 portals, numbered by integers from 1 to n - 1. The i-th (1 ≤ i ≤ n - 1) portal connects cell i and cell (i + a_{i}), and one can travel from cell i to cell (i + a_{i}) using the i-th portal. Unfortunately, one cannot use the portal backwards, which means one cannot move from cell (i + a_{i}) to cell i using the i-th portal. It is easy to see that because of condition 1 ≤ a_{i} ≤ n - i one can't leave the Line World using portals.

Currently, I am standing at cell 1, and I want to go to cell t. However, I don't know whether it is possible to go there. Please determine whether I can go to cell t by only using the construted transportation system.


-----Input-----

The first line contains two space-separated integers n (3 ≤ n ≤ 3 × 10^4) and t (2 ≤ t ≤ n) — the number of cells, and the index of the cell which I want to go to.

The second line contains n - 1 space-separated integers a_1, a_2, ..., a_{n} - 1 (1 ≤ a_{i} ≤ n - i). It is guaranteed, that using the given transportation system, one cannot leave the Line World.


-----Output-----

If I can go to cell t using the transportation system, print "YES". Otherwise, print "NO".


-----Examples-----
Input
8 4
1 2 1 2 1 2 1

Output
YES

Input
8 5
1 2 1 2 1 1 1

Output
NO



-----Note-----

In the first sample, the visited cells are: 1, 2, 4; so we can successfully visit the cell 4.

In the second sample, the possible cells to visit are: 1, 2, 4, 6, 7, 8; so we can't visit the cell 5, which we want to visit.

Difficulty: EASY
Tags: Graph algorithms

Graph traversal

Implementation

Starter code:

Solutions:
from collections import deque

def solve(pairs, target):

	def _bfs(src):
		q = deque()
		q.append(src)
		while len(q):
			node = q.popleft()
			if node == target:
				print('YES')
				return
			if node > target:
				print('NO')
				return
			neighbor = pairs[node - 1]
			q.append(neighbor + node)
	_bfs(1)
n = list(map(int, input().split(' ')))
target = n[1]
pairs = list(map(int, input().split(' ')))
solve(pairs, target)


def main():
	(size_world, destination) = map(int, input().split())
	portals = list(map(int, input().split()))
	node = 0
	while node < destination - 1:
		node += portals[node]
	if node == destination - 1:
		print('YES')
	else:
		print('NO')
main()


(n, t) = map(int, input().split())
skips = [int(x) for x in input().split()]
position = 1
while position <= n:
	if position == t:
		print('YES')
		exit(0)
	if position > t:
		break
	if position == n:
		break
	step = skips[position - 1]
	position += step
print('NO')


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
(d, f) = (1, 0)
while d < m:
	d += l[d - 1]
	if d == m:
		f = 1
		break
	elif d > m:
		break
print(['NO', 'YES'][f == 1])


import math
firstLineInputs = list(map(int, input().split()))
amount = firstLineInputs[0]
target = firstLineInputs[1]
increments = list(map(int, input().split()))
graph = {}
for i in range(1, target):
	x = i + increments[i - 1]
	if x <= target:
		graph[str(i)] = str(x)
start = '1'
while True:
	if str(target) == start:
		print('YES')
		break
	if start in graph:
		start = graph[start]
	else:
		print('NO')
		break


(n, f) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
c = 1
while True:
	if c == f:
		print('YES')
		break
	elif c > f:
		print('NO')
		break
	c = c + a[c - 1]


def New_year(lis2, t1):
	i = 1
	while i < t1:
		i = i + lis2[i - 1]
	if i == t1:
		return 'YES'
	else:
		return 'NO'
(n, t) = map(int, input().split())
lis = list(map(int, input().split()))
print(New_year(lis, t))


f = lambda : map(int, input().split())
(n, t) = f()
l = list(map(int, input().split()))
s = 0
p = 1
test = False
if p == t:
	print('YES')
else:
	while s < t:
		s = l[p - 1] + p
		p = s
if s == t:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
p = 1
while p < t:
	p += a[p - 1]
if p == t:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
p = []
i = 1
p.append(i)
while i < n:
	i = a[i - 1] + i
	p.append(i)
if t in p:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
x = list(map(int, input().split()))
t -= 1
cur = 0
while cur < n - 1:
	if cur == t:
		print('YES')
		quit()
	cur += x[cur]
if cur == t:
	print('YES')
else:
	print('NO')


import sys
nums = [int(x) for x in sys.stdin.readline().split(' ')]
a = [int(x) for x in sys.stdin.readline().split(' ')]
t = nums[1]
curr = 1
while curr < t:
	curr += a[curr - 1]
if curr == t:
	print('YES')
else:
	print('NO')


I = lambda : map(int, input().split())
(n, t) = I()
a = list(I())
c = 0
while c < t:
	if c == t - 1:
		print('YES')
		break
	c += a[c]
else:
	print('NO')


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
pos = 1
i = 0
while pos < m:
	pos += a[i]
	i += a[i]
if pos == m:
	print('YES')
else:
	print('NO')


(n, t) = [int(x) for x in input().split()]
floors = [int(x) for x in ('0 ' + input()).split()]
i = 1
while i < t:
	i += floors[i]
if i == t:
	print('YES')
else:
	print('NO')


from array import *
(n, t) = input().split(' ')
n = int(n)
t = int(t)
x = 1
arr = list(map(int, input().split()))
while x < t:
	x += arr[x - 1]
if x == t:
	print('YES')
else:
	print('NO')


import sys

class Scanner:

	def __init__(self):
		self.current_tokens = []

	def remaining_tokens(self):
		return len(self.current_tokens)

	def nextline(self):
		assert self.remaining_tokens() == 0, 'Reading next line with remaining tokens'
		return input()

	def nexttokens(self):
		return self.nextline().split()

	def nexttoken(self):
		if len(self.current_tokens) == 0:
			self.current_tokens = self.nexttokens()
		assert self.remaining_tokens() > 0, 'Not enough tokens to parse.'
		return self.current_tokens.pop(0)

	def nextints(self, n=-1):
		if n == -1:
			return list(map(int, self.nexttokens()))
		else:
			return (self.nextint() for i in range(n))

	def nextint(self):
		return int(self.nexttoken())

def quit():
	sys.exit(0)
stdin = Scanner()
nextint = stdin.nextint
nextints = stdin.nextints
nextline = stdin.nextline
(n, t) = nextints(2)
a = nextints()
z = 1
while z <= t:
	if z == t:
		print('YES')
		quit()
	else:
		z += a[z - 1]
print('NO')


p = input
i = int
f = lambda : map(i, p().split())
(n, t) = f()
s = list(f())
i = 1
while i < t:
	i += s[i - 1]
print('YNEOS'[i > t::2])


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as c
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var))

def outln(var):
	sys.stdout.write(str(var) + '\n')

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
graph = dd(set)
(n, t) = sp()
arr = l()
for i in range(n - 1):
	(u, v) = (i + 1, i + 1 + arr[i])
	graph[u].add(v)
d = deque()
d.append(1)
result = False
while d:
	temp = d.popleft()
	if temp == t:
		result = True
		break
	for child in graph[temp]:
		d.append(child)
if result:
	out('YES')
	exit()
out('NO')


(n, d) = map(int, input().split())
a = list(map(int, input().split()))
q = 1
while q < n:
	q = a[q - 1] + q
	if q == d:
		print('YES')
		exit(0)
print('NO')


(n, t) = map(int, input().split())
s = list(map(int, input().split()))
tile = 1
try:
	for i in s:
		tile += s[tile - 1]
		if tile == t:
			print('YES')
			exit()
	else:
		print('NO')
except IndexError:
	print('NO')


(n, t) = map(int, input().split())
a = [int(x) for x in input().split()]
p = 1
flag = False
while p <= n:
	if p == t:
		flag = True
		break
	if p >= n:
		break
	p += a[p - 1]
if flag:
	print('YES')
else:
	print('NO')


l1 = [int(x) for x in input().split()]
l2 = [int(x) for x in input().split()]
end = l1[1]
start = 1
while start < end:
	start += l2[start - 1]
if start == end:
	print('YES')
else:
	print('NO')


(n, t) = [int(x) for x in input().split()]
cells = [int(x) for x in input().split()]
position = 1
for i in range(0, n):
	if position > t:
		print('NO')
		exit()
	elif position == t:
		print('YES')
		exit()
	else:
		position += cells[position - 1]


def main():
	(n, t) = map(int, input().split())
	l = [None]
	l.extend(map(int, input().split()))
	i = 1
	while True:
		if i == t:
			print('YES')
			return
		if i < n:
			i += l[i]
		else:
			break
	print('NO')
main()


(n, t) = map(int, input().split())
s = list(map(int, input().split()))
i = 1
while i <= t:
	if i == t:
		print('YES')
		break
	else:
		i = i + s[i - 1]
if i > t:
	print('NO')


import sys
(n, t) = list(map(int, input().split()))
A = list(map(int, input().split()))
A.append(n)
cur = 0
while cur <= n - 1:
	if cur == t - 1:
		print('YES')
		sys.exit(0)
	cur += A[cur]
print('NO')


para = input().split(' ')
n = int(para[0])
t = int(para[1]) - 1
a = [int(i) for i in input().split(' ')]
index = 0
has_arrived = False
while index < t:
	index += a[index]
	if index == t:
		has_arrived = True
if has_arrived:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split(' '))
a = list(map(int, input().split()))
i = 1
f = 0
while i <= n:
	if i < t:
		i = i + a[i - 1]
	else:
		if i == t:
			f = 1
		break
if f == 1:
	print('YES')
else:
	print('NO')


(n, t) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
i = 0
while True:
	i = i + a[i]
	if t == i + 1:
		print('YES')
		break
	if t < i + 1:
		print('NO')
		break
	if i > len(a) - 1:
		break


(n, k) = map(int, input().split())
c = list(map(int, input().split()))
x = 0
k = k - 1
while x < k:
	x += c[x]
if x == k:
	print('YES')
else:
	print('NO')


n = input().split(' ')
m = input().split(' ')
y = int(n[1])
x = []
for i in range(len(m)):
	x.append(int(m[i]))
i = 1
while i < y:
	i += x[i - 1]
if i == y:
	print('YES')
else:
	print('NO')


(n, target) = [int(i) for i in input().strip().split()]
path = [int(i) for i in input().strip().split()]
i = 1
while i < target:
	i += path[i - 1]
if i == target:
	print('YES')
else:
	print('NO')


import sys
import math
from collections import Counter
from collections import OrderedDict
from collections import defaultdict
from functools import reduce
sys.setrecursionlimit(10 ** 6)

def inputt():
	return sys.stdin.readline().strip()

def printt(n):
	sys.stdout.write(str(n) + '\n')

def listt():
	return [int(i) for i in inputt().split()]

def gcd(a, b):
	return math.gcd(a, b)

def lcm(a, b):
	return a * b // gcd(a, b)

def factors(n):
	step = 2 if n % 2 else 1
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(math.sqrt(n)) + 1, step) if n % i == 0)))

def comb(n, k):
	factn = math.factorial(n)
	factk = math.factorial(k)
	fact = math.factorial(n - k)
	ans = factn // (factk * fact)
	return ans

def is_prime(n):
	if n <= 1:
		return False
	if n == 2:
		return True
	if n > 2 and n % 2 == 0:
		return False
	max_div = math.floor(math.sqrt(n))
	for i in range(3, 1 + max_div, 2):
		if n % i == 0:
			return False
	return True

def maxpower(n, x):
	B_max = int(math.log(n, x)) + 1
	return B_max
t = 1
for _ in range(t):
	(n, k) = map(int, inputt().split())
	l = listt()
	d = {}
	for i in range(n - 1):
		d[i + 1] = l[i] + i + 1
	c = 1
	ko = False
	while c <= k:
		c = d[c]
		if c == k:
			print('YES')
			ko = True
			break
	if ko == False:
		print('NO')


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
i = 1
while i < t:
	i += a[i - 1]
print('YNEOS'[i != t::2])


b = [int(x) for x in input().split()]
n = b[0]
t = b[1]
a = [int(x) for x in input().split()]
tren = 0
uvjet = 0
t -= 1
while True:
	if tren == t:
		print('YES')
		uvjet = 1
		break
	if tren > t:
		break
	else:
		tren = tren + a[tren]
if uvjet == 0:
	print('NO')


(n, t) = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
d = False
x = 1
while x - 1 < n:
	if x == t:
		d = True
		break
	if x - 1 >= len(l):
		break
	x += l[x - 1]
print('YES' if d else 'NO')


def main():
	(n, t) = read()
	a = read()
	c = 1
	while c < t:
		c += a[c - 1]
	if c == t:
		print('YES')
	else:
		print('NO')

def read(mode=2):
	inputs = input().strip()
	if mode == 0:
		return inputs
	if mode == 1:
		return inputs.split()
	if mode == 2:
		return list(map(int, inputs.split()))

def write(s='\n'):
	if s is None:
		s = ''
	if isinstance(s, list):
		s = ' '.join(map(str, s))
	s = str(s)
	print(s, end='')
write(main())


def solve(dest, cells):
	idx = 0
	while idx < dest:
		idx += cells[idx]
	return idx == dest
(_, destination) = map(int, input().split())
cells = list(map(int, input().split()))
print('YES' if solve(destination - 1, cells) else 'NO')


(n, t) = map(int, input().split())
l = [int(x) for x in input().split()]
a = 0
while a < t - 1:
	a += l[a]
if a == t - 1:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
cells = [int(u) for u in input().split()]
i = 1
while True:
	i += cells[i - 1]
	if i == t:
		print('YES')
		break
	elif i > n - 1:
		print('NO')
		break


(n, t) = map(int, input().split())
vet = list(map(int, input().split()))
i = 1
while True:
	if i >= t:
		break
	i = i + vet[i - 1]
if i == t:
	print('YES')
else:
	print('NO')


(t, lst, i) = (int(input().split()[1]), list(map(int, input().split())), 1)
while i < t:
	i += lst[i - 1]
print(['YES', 'NO'][i != t])


(x, y) = map(int, input().split())
l = list(map(int, input().split()))
i = 1
cnt = 0
while i < y:
	i += l[i - 1]
if i == y:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
s = tuple(map(int, input().split()))
i = 1
ans = 'NO'
while i <= t:
	i = i + s[i - 1]
	if i == t:
		ans = 'YES'
		break
print(ans)


input1 = input().split()
portals = [int(x) for x in input().split()]
target_index = int(input1[1]) - 1
length = int(input1[0])
current_index = 0
while current_index < target_index:
	current_index += portals[current_index]
if current_index == target_index:
	print('YES')
else:
	print('NO')


(n, t) = list(map(int, input().split()))
l = input().split()
for i in range(n - 1):
	l[i] = int(l[i])
l = [0] + l
now = 1
while 1:
	now += l[now]
	if now > t:
		ans = 0
		break
	if now == t:
		ans = 1
		break
if ans == 0:
	print('NO')
else:
	print('YES')


(n, dest) = [int(i) for i in input().split(' ')]
steps = [int(i) for i in input().split(' ')]
res = 'NO'
currentHouse = 1
while currentHouse < dest:
	nextHouse = currentHouse + steps[currentHouse - 1]
	if nextHouse == dest:
		res = 'YES'
	currentHouse = nextHouse
print(res)


inp1 = input().split()
n = int(inp1[0])
t = int(inp1[1])
paths = input().split()
paths = [int(i) for i in paths]
links = {}
for index in range(len(paths)):
	links[index + 1] = paths[index] + index + 1
initial = links.keys()
end = links.values()
dest = 1
while True:
	if links[dest] == t:
		search = True
		break
	elif links[dest] not in initial:
		search = False
		break
	else:
		dest = links[dest]
if search:
	print('YES')
else:
	print('NO')


T = lambda : list(map(int, input().split()))
(n, t) = T()
lista = T()
p = 1
i = 0
for _ in range(n - 1):
	if p == t:
		break
	elif p < n:
		p += lista[p - 1]
		if p > n:
			p = p - n
			break
print(['NO', 'YES'][p == t])


(n, q) = map(int, input().split())
L = map(int, input().split())
L = list(L)
V = [1]
while True:
	try:
		V.append(V[-1] + L[V[-1] - 1])
	except:
		break
rep = 'No'
if q in V:
	rep = 'Yes'
print(rep)


from collections import defaultdict

class Graph:

	def __init__(self, vertices):
		self.V = vertices
		self.graph = defaultdict(list)

	def addEdge(self, u, v):
		self.graph[u].append(v)

	def isReachable(self, s, d):
		visited = [False] * self.V
		queue = []
		queue.append(s)
		visited[s] = True
		while queue:
			n = queue.pop(0)
			if n == d:
				return True
			for i in self.graph[n]:
				if visited[i] == False:
					queue.append(i)
					visited[i] = True
		return False
(n, t) = map(int, input().split())
g = Graph(n)
arr = [int(x) for x in input().split()]
for i in range(n - 1):
	g.addEdge(i, i + arr[i])
u = 0
v = t - 1
if g.isReachable(u, v):
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
cp = 0
while cp < t - 1:
	cp += a[cp]
if cp == t - 1:
	print('YES')
else:
	print('NO')


(n, s) = map(int, input().split())
a = [int(x) for x in input().split()]
start = 1
visited = set([])
visited.add(start)
while start != n:
	start += a[start - 1]
	visited.add(start)
if s in visited:
	print('YES')
else:
	print('NO')


import sys
from collections import Counter as counter
cin = sys.stdin.readline
cout = sys.stdout.write

def func(n, t, l):
	i = 1
	if i == t:
		return 'YES'
	while i <= t:
		i += l[i - 1]
		if i == t:
			return 'YES'
	return 'NO'

def main():
	(n, t) = map(int, input().split())
	l = list(map(int, input().split()))
	st = str(func(n, t, l))
	print(st)
main()


(n, t) = input().split()
(n, t) = (int(n), int(t))
str_arr = input().split(' ')
a = [int(num) for num in str_arr]
i = 1
x = a[i - 1]
while i < t and i + x <= n:
	i += x
	if i < n:
		x = a[i - 1]
	if i == t:
		print('YES')
		break
else:
	print('NO')


def checkFound():
	i = 0
	while i < n:
		if i == t:
			print('YES')
			return
		else:
			i = i + arr[i]
	print('NO')
(n, t) = map(int, input().split())
arr = list(map(int, input().split()))
arr.append(1)
t -= 1
checkFound()


(n, y) = map(int, input().split())
x = []
y -= 1
x.extend(map(int, input().split()))
poin = 0
while poin < y and poin < n:
	poin += x[poin]
if poin == y:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
nums = [int(x) for x in input().split()]
steps = 0
count = 0
while steps < n:
	if count + 1 < t:
		count += nums[count]
	else:
		break
if count + 1 == t:
	print('YES')
else:
	print('NO')


from collections import defaultdict as dc
(n, k) = map(int, input().split())
g = dc(int)
l = list(map(int, input().split()))
for i in range(n - 1):
	g[i + 1] = i + 1 + l[i]
s = 1
f = [0] * (n + 1)
q = []
q.append(s)
p = 1
f[1] = 1
t = 0
while p > 0:
	x = q.pop()
	p -= 1
	if x == k:
		t = 1
		break
	if f[g[x]] == 0:
		q.append(g[x])
		f[g[x]] = 1
		p += 1
if t:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
l = 0
while l < m - 1:
	l += c[l]
if l == m - 1:
	print('YES')
else:
	print('NO')


from collections import defaultdict
(n, t) = map(int, input().split())
a = list(map(int, input().split()))
curr = 1
while curr != t and curr < n:
	curr = curr + a[curr - 1]
if curr == t:
	print('YES')
else:
	print('NO')


ni = input().split(' ')
(n, i) = [int(x) for x in ni]
numbers = input().split(' ')
numbers = [int(x) for x in numbers]
j = 0
passed = False
while j < i:
	j = j + numbers[j]
	if j == i - 1:
		print('YES')
		passed = True
		break
if not passed:
	print('NO')


(q, w) = map(int, input().split())
d = list(map(int, input().strip().split()))
t = 0
for i in range(q):
	if t == w - 1:
		print('YES')
		break
	elif t >= w:
		print('NO')
		break
	t = t + d[t]


(n, t) = list(map(int, input().split()))
t = t - 1
j = [int(x) for x in input().split()]
cur = 0
while True:
	if cur > t:
		print('NO')
		break
	cur += j[cur]
	if cur == t:
		print('YES')
		break


(n, index) = map(int, input().split())
cells = list(map(int, input().split()))
i = 1
while i <= len(cells):
	i = i + cells[i - 1]
	if i == index:
		print('YES')
		exit(0)
print('NO')


from functools import reduce
import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def arr():
	return [int(i) for i in input().split()]

def sarr():
	return [int(i) for i in input()]

def inn():
	return int(input())
(n, k) = value()
a = arr()
i = 0
flag = 0
while i < n - 1:
	if i == k - 1:
		flag = 1
		break
	i += a[i]
if i == n - 1 and k == n:
	flag = 1
if flag:
	print('YES')
else:
	print('NO')


import math, string, itertools, fractions, heapq, collections, re, array, bisect
from itertools import chain, dropwhile, permutations, combinations
from collections import defaultdict

def main(n, t, a):
	j = 1
	while j < n:
		j += a[j - 1]
		if j == t:
			print('YES')
			return
	print('NO')

def main_input():
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	main(n, t, a)
main_input()


(n, t) = map(int, input().split())
a = [int(i) for i in input().split()]
s = 0
t = t - 1
while s <= n - 1:
	if s == t:
		print('YES')
		break
	elif s > t:
		print('NO')
		break
	elif s < t:
		s = s + a[s]


(a, b) = map(int, input().split())
c = list(map(int, input().split()))
d = 1
while d < b:
	d = d + c[d - 1]
if d == b:
	print('Yes')
else:
	print('No')


(n, t) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
i = 0
j = 1
while i < t:
	i = j + a[j - 1]
	if i == t:
		print('YES')
		break
	elif i > t:
		print('NO')
		break
	j = i


(n, final) = [int(i) for i in input().split()]
piece = [int(i) for i in input().split()]
tunnel = {}
for i in range(1, n):
	tunnel[i] = i + piece[i - 1]
start = 1
dest = [1]
while start < n:
	end = tunnel[start]
	dest.append(end)
	start = end
if final in dest:
	print('YES')
else:
	print('NO')


((n, t), a) = (map(int, input().split()), list(map(int, input().split())))
x = 0
while x != t - 1 and x != n - 1:
	x += a[x]
print('YES' if x == t - 1 else 'NO')


(a, b) = map(int, input().split())
d = list(map(int, input().split()))
i = 0
while i < b - 1:
	i += d[i]
if i == b - 1:
	print('YES')
else:
	print('NO')


n = [int(i) for i in input().split()]
z = [int(i) for i in input().split()]
c = 0
j = 1
for i in range(1, n[0]):
	j += z[j - 1]
	if j == n[1]:
		print('YES')
		c = 1
		break
	if j > n[1]:
		break
if c == 0:
	print('NO')


str1 = input()
L1 = str1.split(' ')
str2 = input()
L2 = str2.split(' ')
n = int(L1[1])
state = False
i = 1
while i <= len(L2):
	if i != n:
		i += int(L2[i - 1])
	else:
		state = True
		break
if i == n:
	state = True
if state:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
i = 1
dovesono = 1
while i < n:
	if 1 <= a[i - 1] <= n - i:
		dovesono = i + a[i - 1]
		i = dovesono
	if dovesono == t:
		print('YES')
		break
	elif dovesono > t:
		print('NO')
		break


(x, y) = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]
n = 0
while n < y - 1:
	n = n + int(l[n])
if n == y - 1:
	print('YES')
else:
	print('NO')


(n, t) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

def f(z):
	return z + a[z - 1]
i = 1
while i <= n:
	i = f(i)
	if i == t:
		print('YES')
		break
	elif i > t:
		print('NO')
		break


(n, t) = map(int, input().split())
a_s = list(map(int, input().split()))
pos = 1
while pos < t:
	pos += a_s[pos - 1]
if pos == t:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
L = list(map(int, input().split()))
r = 1
while r != t and r < n:
	r = r + L[r - 1]
if r == t:
	print('YES')
else:
	print('NO')


def possible(adj, s, t, n):
	que = []
	que.append(s)
	visited = [False] * (n + 1)
	visited[s] = True
	while que:
		x = que.pop(0)
		if x == t:
			return True
		if x in adj:
			for i in adj[x]:
				if not visited[i]:
					que.append(i)
					visited[i] = True
	return False
(n, t) = map(int, input().split())
l = list(map(int, input().split()))
adj = {}
for i in range(1, n):
	adj[i] = []
for i in range(1, n):
	adj[i].append(i + l[i - 1])
if possible(adj, 1, t, n):
	print('YES')
else:
	print('NO')


x = list(map(int, input('').split()))
y = list(map(int, input('').split()))
t = []
i = 1
t.append(1)
while i <= len(y):
	i = i + y[i - 1]
	t.append(i)
	if i == x[1]:
		print('YES')
		break
if x[1] not in t:
	print('NO')


(n, t) = input().strip().split(' ')
n = int(n)
t = int(t)
a = [int(i) for i in input().strip().split(' ')]
i = 0
flag = 0
while i < len(a):
	j = i + 1 + a[i]
	if j == t:
		flag = 1
		break
	i = j - 1
if flag == 1:
	print('YES')
else:
	print('NO')


I = lambda : map(int, input().split())
(n, t) = I()
a = list(I())
c = 0
while c < t - 1:
	c += a[c]
print('YNEOS'[c >= t::2])


(n, t) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
cur = 1
while cur < t:
	cur += a[cur - 1]
if cur == t:
	print('YES')
else:
	print('NO')


(n, m) = [int(t) for t in input().split()]
value = [int(i) for i in input().split()]
t = 1
while t < n:
	t = t + value[t - 1]
	if t == m:
		print('YES')
		exit()
print('NO')


from sys import stdin, stdout
from math import ceil, floor, sqrt
from collections import deque, Counter
inp = stdin.readline
out = stdout.write
(n, t) = map(int, inp().strip().split())
a = [0] + list(map(int, inp().strip().split()))
f = 1
while f < t:
	f += a[f]
if f == t:
	out('YES')
else:
	out('NO')


import sys
input = sys.stdin.readline
(n, t) = map(int, sys.stdin.readline().split())
a = list(map(int, sys.stdin.readline().split()))
d = []
key = 1
while key not in d and key < t:
	d.append(key)
	key = key + a[key - 1]
if key == t:
	print('YES')
else:
	print('NO')


(a, b) = map(int, input().split())
cells = list(map(int, input().split()))
sum = 1
while sum < b:
	sum = sum + cells[sum - 1]
if sum == b:
	print('YES')
else:
	print('NO')


import sys
(n, t) = map(int, input().split())
values = list(map(int, sys.stdin.readline().split()))
i = 0
while i <= t - 1:
	if i == t - 1:
		print('YES')
		exit()
	i += values[i]
print('NO')


def ans(arr, t):
	x = 1
	while x < t:
		x += arr[x - 1]
	if x == t:
		print('YES')
	else:
		print('NO')
(n, t) = map(int, input().split())
arr = [int(x) for x in input().split()]
ans(arr, t)


(n, t) = map(int, input().split())
a = [int(x) for x in input().split()]
portal = []
go = 1
for i in range(len(a)):
	portal.append([i + 1, i + 1 + a[i]])
while t > go:
	go = portal[go - 1][1]
if t == go:
	print('YES')
else:
	print('NO')


(n, t) = [int(k) for k in input().split(' ')]
portals = [int(k) for k in input().split(' ')]
t -= 1
i = 0
while i < t:
	i += portals[i]
if i > t:
	print('NO')
else:
	print('YES')


(n, t) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = []
for i in range(n):
	b.append(i)
for i in range(n - 1):
	b[i] += a[i]
t = t - 1
i = 0
while i <= n:
	if i == t:
		print('YES')
		break
	if b[i] > t:
		print('NO')
		break
	i = b[i]


array = []
flag = False
(n, t) = map(int, input().split())
mas = list(map(int, input().split()))
for i in range(0, len(mas)):
	array.append(mas[i])
i = 0
while i < n:
	if i + 1 == t:
		flag = True
		break
	else:
		if i >= n - 1:
			break
		i += array[i]
if flag == True:
	print('YES')
else:
	print('NO')


(N, T) = map(int, input().split(' '))
moves = list(map(int, input().split(' ')))
cell = 1
while cell < T:
	cell += moves[cell - 1]
print('YES' if cell == T else 'NO')


from collections import defaultdict
import copy
INF = float('Inf')

class Graph:

	def __init__(self):
		self.graph = defaultdict(list)
		self.keys = set()
		self.V = self.noe = self.numberOfEdges = 0

	def addEdge(self, u, v, w=1):
		if v in self.graph[u]:
			return
		self.keys.add(u)
		self.keys.add(v)
		self.graph[u].append(v)
		self.V += 1

	def BFS(self, s):
		visited = [False] * (max(self.keys) + 1)
		(queue, bfs) = ([], [])
		queue.append(s)
		visited[s] = True
		while queue:
			t = queue.pop(0)
			bfs.append(t)
			for i in self.graph[t]:
				if visited[i] == False:
					queue.append(i)
					visited[i] = True
		return bfs

def solutionTwo():
	(n, t) = map(int, input().split(' '))
	ps = portals = list(map(int, input().split(' '))) + [1]
	g = Graph()
	for (i, p) in enumerate(ps):
		g.addEdge(1 + i, 1 + i + p)
	print('YES' if t in g.BFS(1) else 'NO')
solutionTwo()


(n, t) = map(int, input().split())
data = [int(x) for x in input().split()]
i = 1
while i < n:
	if i == t:
		print('YES')
		exit(0)
	i = i + data[i - 1]
if i == t:
	print('YES')
else:
	print('NO')


(n, t) = [int(_) for _ in input().split()]
a = [int(_) for _ in input().split()]
p = 1
while p < t:
	p += a[p - 1]
if p == t:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
sp = list(map(int, input().split()))
sp.append(0)
used = [0] * (n + 1)
count = 0
while used[count] == 0 and count != n:
	if count + 1 == t:
		print('YES')
		exit()
	used[count] = 1
	count += sp[count]
print('NO')


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
x = 1
while x <= n:
	x = x + a[x - 1]
	if x == t:
		print('YES')
		break
	if x > t:
		print('NO')
		break


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
i = 0
while k - 1 > i:
	i += a[i]
print(['NO', 'YES'][i + 1 == k])


(n, index) = map(int, input().split())
arr = list(map(int, input().split()))
j = 0
f = False
n = n - 1
while j < n:
	j = j + arr[j]
	if j == index - 1:
		f = True
		break
if f:
	print('YES')
else:
	print('NO')


nt = input().split()
n = int(nt[0])
t = int(nt[1])
linearworld = input().split()
linearworld = [int(x) for x in linearworld]
index = 1
i = 0
while index <= t:
	if index == t:
		print('YES')
		exit()
	index += linearworld[i]
	i += linearworld[i]
print('NO')


(n, t) = map(int, input().split(' '))
trans = list(map(int, input().split(' ')))
i = 0
flag = False
while i < t:
	if trans[i] + (i + 1) == t:
		flag = True
		break
	else:
		i = trans[i] + i
if flag:
	print('YES')
else:
	print('NO')


(n, t) = list(map(int, input().split()))
portals = list(map(int, input().split()))
pos = 1
flag = 0
for i in range(n - 1):
	if pos < t:
		pos += portals[pos - 1]
	elif pos == t:
		flag = 1
		print('YES')
		break
	elif pos > t:
		flag = 2
		print('NO')
		break
if flag == 0:
	print('YES')


(n, k) = [int(x) for x in input().split()]
x = [int(x) for x in input().split()]
cnt = 0
while cnt <= n - 1:
	if cnt == k - 1:
		print('YES')
		break
	elif cnt > k - 1:
		print('NO')
		break
	cnt += x[cnt]


(n, t) = input().split()
p = [int(i) for i in input().split()]
l = []
a = p[0] + 1
l.append(a)
while a < int(n):
	a = p[a - 1] + a
	l.append(a)
if int(t) in l:
	print('YES')
else:
	print('NO')


(n, t) = input().split()
(n, t) = (int(n), int(t))
portal = [int(x) for x in input().split()]
cur = 0
for i in range(n - 1):
	cur = cur + portal[cur]
	if cur == t - 1:
		print('YES')
		break
	elif cur > t - 1:
		print('NO')
		break
else:
	print('NO')


(n, t) = map(int, input().split())
next = {i: i + a for (i, a) in zip(range(1, n), map(int, input().split()))}
cell = 1
while cell < t:
	cell = next[cell]
print('YES' if cell == t else 'NO')


(n, m) = map(int, input().split())
s = [int(i) for i in input().split()]
F = False
i = 1
while i <= m and i < n:
	i = s[i - 1] + i
	if m == i:
		F = True
if F == True or m == 1:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
l = list(map(int, input().split()))
f = 0
m = 1
while True:
	m = m + l[m - 1]
	if m == t:
		f = 1
		break
	if m >= n:
		break
if f == 0:
	print('NO')
else:
	print('YES')


from sys import stdin, stdout
import bisect
import math
from collections import deque
mod = 10 ** 9 + 7

def st():
	return list(stdin.readline().strip())

def inp():
	return int(stdin.readline())

def li():
	return list(map(int, stdin.readline().split()))

def mp():
	return map(int, stdin.readline().split())

def pr(n):
	stdout.write(str(n) + '\n')

def DFS(d, i, visited):
	visited[i] = True
	stack = [i]
	while stack:
		a = stack.pop()
		for i in d[a]:
			if not visited[i]:
				visited[i] = True
				stack.append(i)

def soe(limit):
	l = [1] * (limit + 1)
	l[0] = 0
	l[1] = 0
	prime = []
	for i in range(2, limit + 1):
		if l[i]:
			for j in range(i * i, limit + 1, i):
				l[j] = 0
	for i in range(2, limit + 1):
		if l[i]:
			prime.append(i)
	return prime

def segsoe(low, high):
	limit = int(high ** 0.5) + 1
	prime = soe(limit)
	n = high - low + 1
	l = [0] * (n + 1)
	for i in range(len(prime)):
		lowlimit = low // prime[i] * prime[i]
		if lowlimit < low:
			lowlimit += prime[i]
		if lowlimit == prime[i]:
			lowlimit += prime[i]
		for j in range(lowlimit, high + 1, prime[i]):
			l[j - low] = 1
	for i in range(low, high + 1):
		if not l[i - low]:
			if i != 1:
				print(i)

def gcd(a, b):
	while b:
		a = a % b
		(b, a) = (a, b)
	return a

def power(a, n):
	r = 1
	while n:
		if n & 1:
			r = r * a
		a *= a
		n = n >> 1
	return r

def solve():
	(n, k) = mp()
	l = li()
	l = [0] + l
	d = {i: [] for i in range(1, n + 1)}
	for i in range(1, n):
		d[i].append(i + l[i])
	visited = [False for i in range(n + 1)]
	DFS(d, 1, visited)
	if visited[k]:
		pr('YES')
	else:
		pr('NO')
for _ in range(1):
	solve()


(n, t) = map(int, input().split())
s = list(map(int, input().split()))
d = 1
while n > 0:
	n -= 1
	d += s[d - 1]
	if d == t:
		print('YES')
		exit()
	elif d > t:
		print('NO')
		exit()


(n, m) = map(int, input().split())
ar = list(map(int, input().split()))
A = []
for (ind, it) in enumerate(ar):
	A.append(it + ind + 1)
i = 0
while A[i] < m:
	i = A[i] - 1
if A[i] == m:
	print('YES')
else:
	print('NO')


line = input().split(' ')
n = int(line[0])
s = 1
t = int(line[1])
cells = [i for i in range(1, n + 1)]
a_list = [int(a) for a in input().split(' ')]
portals = []
for i in range(n - 1):
	portals.append(i + 1 + a_list[i])
if len(set(a_list)) == 1:
	print('YES')
else:
	stack = [s]
	visited = []
	while stack:
		top = stack.pop(-1)
		visited.append(top)
		if top == t:
			print('YES')
			break
		if top == n:
			print('NO')
			break
		adj = portals[top - 1]
		if adj not in visited:
			stack.append(adj)


from sys import stdin, stdout
(n, t) = [int(c) for c in stdin.readline().split()]
s = [int(c) for c in stdin.readline().split()]
p = 1
while True:
	p = p + s[p - 1]
	if p == t:
		print('YES')
		break
	elif p >= t:
		print('NO')
		break


(n, t) = map(int, input().split())
m = [int(i) for i in input().split()]
q = 1
while q < t:
	q += m[q - 1]
if t == q:
	print('YES')
else:
	print('NO')


from sys import stdin
(n, t) = [int(x) for x in stdin.readline().split()]
celdas = []
celdas.append(0)
celdas = [int(x) for x in stdin.readline().split()]
flag = False
acum = 0
i = 0
while acum != t and acum < n:
	if acum == t:
		flag = True
		break
	acum += celdas[acum - 1]
	if acum == t:
		flag = True
		break
if flag:
	print('YES')
else:
	print('NO')


from collections import deque

class Graph:

	def __init__(self, n):
		self.n = n
		self.adj = [set() for _ in range(n)]

	def __len__(self):
		return self.n

	def add_edge(self, u, v):
		self.adj[u].add(v)

	def nodes(self):
		return range(self.n)

	def edges(self):
		for u in self.nodes():
			for v in self.successors(u):
				yield (u, v)

	def successors(self, u):
		return self.adj[u]

def bfs(graph, source, target):
	vis = [False] * len(graph)
	vis[source] = True
	pred = [None] * len(graph)
	q = deque()
	q.appendleft(source)
	while q:
		u = q.pop()
		if u == target:
			return pred
			return True
		for v in graph.successors(u):
			if not vis[v]:
				vis[v] = True
				pred[v] = u
				q.appendleft(v)
	return False
header = [int(x) for x in input().split()]
portals = [int(x) for x in input().split()]
n = header[0]
target = header[1]
g = Graph(n)
for (i, p) in enumerate(portals):
	g.add_edge(i, i + p)
if bfs(g, 0, target - 1):
	print('YES')
else:
	print('NO')


(n, t) = [int(i) for i in input().split()]
a = input().split()
b = []
if t == 1:
	print('YES')
if t != 1:
	i = 0
	while i <= n - 2:
		i = i + int(a[i])
		b.append(i)
	if t - 1 in b:
		print('YES')
	else:
		print('NO')


(n, id) = map(int, input().split())
portal = list(map(int, input().split()))
i = 1
while i <= len(portal):
	i = i + portal[i - 1]
	if i == id:
		print('YES')
		exit(0)
print('NO')


(n, t) = [int(i) for i in input().split()]
tt = [int(i) for i in input().split()]
pos = 1
while pos < t:
	pos += tt[pos - 1]
if pos == t:
	print('YES')
else:
	print('NO')


(n, t) = [int(z) for z in input().split()]
c = [int(z) for z in input().split()]
r = 0
while r < t - 1:
	r += c[r]
if r == t - 1:
	print('YES')
else:
	print('NO')


(n, t) = input().split()
n = int(n)
t = int(t)
s = input().split()
i = 1
while i <= n:
	if t > i + int(s[i - 1]):
		i = i + int(s[i - 1])
		continue
	elif t == i + int(s[i - 1]):
		print('YES')
		break
	else:
		print('NO')
		break


(n, t) = map(int, input().split())
a = []
a.append(0)
arr = list(map(int, input().split()))
for i in range(n - 1):
	a.append(arr[i])
count = 1
arr2 = []
while count < n:
	count = count + a[count]
	arr2.append(count)
if t in arr2:
	print('YES')
else:
	print('NO')


def verificator(cells, t, intergers):
	t -= 1
	current_cell = 0
	while True:
		if current_cell < t:
			current_cell += intergers[current_cell]
		elif current_cell == t:
			return 'YES'
		elif current_cell > t:
			return 'NO'
input_one = str(input())
input_two = str(input())
(cells, t) = (int(input_one.split(' ')[0]), int(input_one.split(' ')[1]))
intergers = []
for interger in input_two.split(' '):
	intergers.append(int(interger))
print(verificator(cells, t, intergers))


(a, b) = map(int, input().split())
c = list(map(int, input().split()))
s = 1
while s < b:
	s += c[s - 1]
print(['YES', 'NO'][s > b])


(N, final) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
P = [1]
i = 1
while i <= N - 1:
	i = i + a[i - 1]
	P.append(i)
if final in P:
	print('YES')
else:
	print('NO')


(n, dest) = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
arr += [0] * (n - len(arr))
j = 0
while True:
	if j + 1 == dest:
		print('YES')
		break
	if j + 1 > dest or arr[j] == 0:
		print('NO')
		break
	j += arr[j]


def reachable(cells, endGoal, portals):
	position = 1
	if position == endGoal:
		return 'YES'
	while position <= len(portals):
		position += portals[position - 1]
		if position == endGoal:
			return 'YES'
	return 'NO'
(cells, endGoal) = list(map(int, input().split(' ')))
portals = list(map(int, input().split(' ')))
print(reachable(cells, endGoal, portals))


(n, t) = map(int, input().split())
a = [int(i) for i in input().split()]
t -= 1
pos = 0
while pos < t:
	pos += a[pos]
if pos == t:
	print('YES')
else:
	print('NO')


(n, need) = input().split()
list = input().split()
list = [int(i) for i in list]
graph = {}
i = 0
while i <= len(list) - 1:
	graph[i] = i + list[i]
	i = i + list[i]
bool = False
for key in graph:
	if graph[key] == int(need) - 1:
		bool = True
if bool:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
arr = list(map(int, input().split()))
index = [x for x in range(1, n)]
z = list(zip(index, [sum(tup) for tup in zip(index, arr)]))
res = False
pos = 1
i = 0
while pos < t:
	pos = z[i][1]
	i = pos - 1
	if pos == t:
		res = True
print('YES' if res else 'NO')


(n, t) = [int(i) for i in input().split()]
lst = [int(i) for i in input().split()]
c = 1
nk = 0
while True:
	if c < t:
		c = lst[c - 1] + c
	elif c == t:
		print('YES')
		break
	else:
		nk = 1
		break
if nk == 1:
	print('NO')


import math

def inp():
	return int(input())

def inlist():
	return list(map(int, input().split()))

def instr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())
(n, t) = invr()
a = inlist()
res = 'NO'
i = 1
while i < n:
	i = i + a[i - 1]
	if i == t:
		res = 'YES'
		break
if t == 1:
	res = 'YES'
print(res)


(a, b) = map(int, input().split())
c = input().split()
D = {}
for i in range(1, a):
	D[i] = int(c[i - 1])
c = 1
while c < b:
	d = D[c]
	c += d
if c == b:
	print('YES')
else:
	print('NO')


(n, t) = [int(x) for x in input().split()]
l = list(map(int, input().split()))
s = 1
i = 1
te = 0
l.insert(0, 0)
while s < t:
	s = l[s] + s
if s > t:
	print('NO')
if s == t:
	print('YES')


(n, t) = map(int, input().split())
arr = list(map(int, input().split()))
index = 1
while index < t:
	index = index + arr[index - 1]
if index == t:
	print('YES')
else:
	print('NO')


(n, t) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
i = 1
while 1:
	if i >= n:
		print('NO')
		break
	i = a[i - 1] + i
	if i == t:
		print('YES')
		break


from sys import stdin, stdout
ins = stdin
outs = stdout
(n, k) = [int(i) for i in ins.readline().strip().split(' ')]
mas = [int(i) for i in ins.readline().strip().split(' ')]
i = 0
while i < n - 1:
	tmp = mas[i]
	i += tmp
	if i == k - 1:
		outs.write('YES')
		exit()
if k == 1 or n == 2:
	outs.write('YES')
else:
	outs.write('NO')


(n, t) = map(int, input().split())
l = list(map(int, input().split()))
t -= 1
i = 0
while i < t:
	i += l[i]
	if i == t:
		print('YES')
		exit()
print('NO')


(n, t) = map(int, input().split())
l = list(map(int, input().split()))
l.insert(0, 0)
i = 1
while i <= t:
	if i == t:
		print('YES')
		break
	else:
		i = i + l[i]
if i > t:
	print('NO')


a = input().strip().split()
(n, t) = (int(a[0]), int(a[1]))
l = [int(0)]
a = input().strip().split()
for i in range(n - 1):
	l.append(int(a[i]))
ans = 1
while ans < t:
	ans += l[ans]
if ans == t:
	print('YES')
else:
	print('NO')


I = lambda : map(int, input().split())
(n, m) = I()
a = 'NO'
inc = 0
num = input().split()
for x in range(m):
	if inc > x:
		continue
	else:
		inc = x + int(num[x])
	if inc == m - 1:
		a = 'YES'
		break
print(a)


(n, t) = input().split()
n = int(n)
t = int(t)
cell = 1
possible = False
portals = input().split()
for i in range(n - 1):
	portals[i] = int(portals[i])
while cell < n and (not possible):
	cell += portals[cell - 1]
	if cell == t:
		possible = True
if possible:
	print('YES')
else:
	print('NO')


import sys
(n, t) = input().split()
n = int(n)
t = int(t)
l = [int(i) for i in input().split()]
start = 0
for i in range(n):
	try:
		next_cell = int(l[start]) + start + 1
	except:
		break
	if next_cell == t:
		print('YES')
		sys.exit()
	start = next_cell - 1
print('NO')


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
if t > n - 1:
	t = t % (n - 1)
visited = {}
for i in range(n - 1):
	visited[i + 1] = 'NO'
i = 0
while True:
	if i + 1 > n - 1:
		i -= n - 1
	if i + 1 == t:
		print('YES')
		break
	elif visited[i + 1] == 'YES':
		print('NO')
		break
	visited[i + 1] = 'YES'
	i += a[i]


(n, destination) = map(int, input().split())
l = list(map(int, input().split()))
current = 0
while current != destination - 1:
	if current < n - 1:
		current += l[current]
	else:
		print('NO')
		break
	if current == -1:
		print('NO')
		break
else:
	print('YES')


(n, t) = [int(n) for n in input().split()]
cell = [int(cell) for cell in input().split()]

def check():
	m = 1
	while True:
		if m == t:
			return 'YES'
		if m > t:
			return 'NO'
		m = m + cell[m - 1]
print(check())


(n, t) = map(int, input().split())
temp = [int(i) for i in input().split()]
sorted_edges = [[] for _ in range(n)]
for i in range(n - 1):
	if temp[i] + i <= t:
		sorted_edges[temp[i] + i].append(i + 1)
pos = t
test_cases = [pos]
test_cases_copy = []
while test_cases != []:
	for current_pos in test_cases:
		if current_pos == 1:
			print('YES')
			exit()
		for num in sorted_edges[current_pos - 1]:
			test_cases_copy.append(num)
	test_cases = test_cases_copy
	test_cases_copy = []
print('NO')


from sys import stdin, stdout
(n, t) = map(int, stdin.readline().split())
a = list(map(int, stdin.readline().split()))
start = 0
ans = 'NO'
while start <= n:
	if start == t - 1:
		ans = 'YES'
		break
	if start < n - 1:
		start += a[start]
	else:
		break
stdout.write('{}\n'.format(ans))


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
s = [0] * n
d = dict()
for (i, k) in enumerate(a):
	s[i] = i + a[i] + 1
	d[i + 1] = s[i]
st = 1
q = 0
for i in range(1, n):
	if st == n:
		break
	k = d[st]
	if k == t:
		q = 1
		break
	st = k
print(('NO', 'YES')[q])


def inp(s):
	j = 0
	a = []
	for i in range(len(s)):
		if s[i] == ' ':
			a.append(int(s[j:i]))
			j = i + 1
		if i == len(s) - 1:
			a.append(int(s[j:]))
	return a
(n, t) = input().split()
t = int(t)
s = input()
a = inp(s)
i = 1
f = 0
while i < t:
	i = i + a[i - 1]
	if i == t:
		f = 1
if f == 1:
	print('YES')
else:
	print('NO')


lst = [int(i) for i in input().split()]
(n, t) = (lst[0], lst[1])
arr = [int(i) for i in input().split()]
arr.append(0)
lst = [False for i in range(0, n)]
(i, fl) = (0, False)
while True:
	if i == t - 1:
		fl = True
		break
	if i >= n - 1:
		break
	i += arr[i]
if fl:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
l = list(map(int, input().split()))
for i in range(n - 1):
	l[i] = l[i] + i + 1
dic = {}
for i in range(n - 1):
	dic[i + 1] = l[i]
dic[n] = n
s = 1
q = []
for i in range(n):
	q.append(s)
	s = dic[s]
q.append(n)
q = set(q)
if (t in q) == True:
	print('YES')
else:
	print('NO')


n = str(input()).split(' ')
find = int(n[1])
ai = str(input()).split(' ')
for i in range(len(ai)):
	ai[i] = int(ai[i])
i = 0
ans = 'NO'
if len(ai) < find:
	ans = 'YES'
else:
	ans = 'NO'
	while i < len(ai):
		if i + 1 == find:
			ans = 'YES'
			break
		i += ai[i]
print(ans)


(n, destination) = list(map(int, input().split()))
arr = list(map(int, input().split()))
d = {}
for i in range(1, n):
	d[i] = arr[i - 1] + i
src = 1
ans = []
while True:
	ans.append(src)
	if src in d:
		src = d[src]
	else:
		break
if destination in ans:
	print('YES')
else:
	print('NO')


k = input()
k = k.split(' ')
n = int(k[0])
t = int(k[1])
a = input()
a = a.split(' ')
for i in range(0, n - 1):
	a[i] = int(a[i])
f = 0
i = 0
while 1:
	if i == t - 1:
		f = 1
		break
	if i > t - 1:
		f = 0
		break
	i = i + a[i]
if f == 1:
	print('YES')
else:
	print('NO')


(a, b) = list(map(int, input().split()))
line = list(map(int, input().split()))
ind = 1
len_ind = 0
while True:
	if ind == b:
		print('YES')
		break
	if ind > b:
		print('NO')
		break
	ind += line[len_ind]
	len_ind += line[len_ind]


(n, t) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
curr = 1
while curr < t:
	curr += a[curr - 1]
if curr == t:
	print('YES')
else:
	print('NO')


def portal(indeks, arr):
	warp = int(arr[indeks - 1]) + int(indeks)
	return warp
i1 = input().split()
n = int(i1[0])
cari = int(i1[1])
slot = [0] * (int(n) - 1)
i2 = input().split(' ')
for i in range(n - 1):
	slot[i] = int(i2[i])
indeks = 1
while indeks != cari:
	indeks = portal(indeks, slot)
	if indeks > cari:
		print('NO')
		break
	elif indeks == cari:
		print('YES')
		break


(n, t) = map(int, input().split())
i = 1
arr = [int(x) for x in input().split()]
while i <= t:
	if i == t:
		print('YES')
		t = -1
		break
	i += arr[i - 1]
if t != -1:
	print('NO')


(n, t) = str(input()).split()
temp_list = str(input()).split()
tar_list = [0]
for i in temp_list:
	temp_pos = tar_list[-1]
	if temp_pos == int(n) - 1:
		break
	tar_list.append(temp_pos + int(temp_list[temp_pos]))
if int(t) - 1 in tar_list:
	print('YES')
else:
	print('NO')


(N, dest_cell_number) = [int(x) for x in input().strip().split()]

class Cell:

	def __init__(self, cell_number, a_value):
		self.cell_number = cell_number
		self.a_value = a_value
		self.next_cell_number = self.getNextCell()

	def getNextCell(self):
		return self.cell_number + self.a_value if self.cell_number + self.a_value < N else False

	def __str__(self):
		return str({'number': self.cell_number, 'a': self.a_value, 'next cell number': self.next_cell_number})
cell_list = []
for (cell_number, a_value) in zip(range(N), [int(x) for x in input().strip().split()] + [float('inf')]):
	cell_list.append(Cell(cell_number, a_value))
visited_cells = []
curr_cell = cell_list[0]
while True:
	visited_cells.append(curr_cell.cell_number)
	if not curr_cell.getNextCell():
		break
	curr_cell = cell_list[curr_cell.getNextCell()]
print('YES' if dest_cell_number - 1 in visited_cells else 'NO')


s = input().split()
y = input().split()
n = int(s[0])
t = int(s[1])
visited = []
y = list(map(int, y))
index = 0
visited.append(1)
while index < n - 1:
	index = index + y[index]
	visited.append(index + 1)
if t in visited:
	print('YES')
else:
	print('NO')


line = input().split()
n = int(line[0])
t = int(line[1])
line = input().split()
arr = [int(num) for num in line]
n = 0
while n < t - 1:
	n += arr[n]
if n == t - 1:
	print('YES')
else:
	print('NO')


def solve(t, portals):
	t -= 1
	curr_pos = 0
	while curr_pos < t:
		curr_pos += portals[curr_pos]
		if curr_pos == t:
			return 'YES'
	return 'NO'

def main():
	(n, t) = map(int, input().split(' '))
	portals = list(map(int, input().split(' ')))
	print(solve(t, portals))
main()


(n, t) = [int(x) for x in input().split()]
ls = [int(x) for x in input().split()]
lt = []
i = 0
while i < n - 1:
	i += ls[i]
	lt.append(i + 1)
print('YES' if t in lt else 'NO')


(x, y) = input().split()
a = input().split()
i = 0
while i < int(y) - 1:
	i = i + int(a[i])
if i == int(y) - 1:
	print('Yes')
else:
	print('No')


import sys
sys.setrecursionlimit(10 ** 6)
(n, k) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
x = 0
k -= 1
for i in range(n + 2):
	if x >= k:
		break
	x += a[x]
if x == k:
	print('YES')
else:
	print('NO')


(n, t) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [0 for i in range(n)]
b[0] = 1
for i in range(n - 1):
	if b[i] == 1:
		b[i + a[i]] = 1
if b[t - 1] == 1:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
arr = list(map(int, input().split()))
i = 0
while i < t - 1:
	i += arr[i]
if i == t - 1:
	print('YES')
else:
	print('NO')


a = input()
b = input()
c = a.split()
d = b.split()
room = 1
while room < int(c[1]):
	room += int(d[room - 1])
if room == int(c[1]):
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
a = [0] * (n + 10)
a = list(map(int, input().split()))
i = 1
arr = [0] * (n * 2)
arr[1] = 1
for i in range(n):
	if arr[i] > 0:
		arr[i + a[i - 1]] = arr[i]
if arr[t] == 0:
	print('NO')
else:
	print('YES')


from collections import deque
(n, t) = map(int, input().split())
g = list(map(int, input().split()))
g.append(0)
reached = [False] * n
q = deque()
q.append(0)
while q:
	v = q.popleft()
	reached[v] = True
	if not reached[v + g[v]]:
		q.append(v + g[v])
print('YES' if reached[t - 1] else 'NO')


(n, t) = map(int, input().split())
l = list(map(int, input().split()))
c = 1
while c != t and c != n:
	c = c + l[c - 1]
if c == t:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split(' '))
l = list(map(int, input().split(' ')))
cell = 1
a = []
for i in range(n - 1):
	if cell == i + 1:
		cell = cell + l[i]
		a.append(cell)
if m in a:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
b = a[0] + 1
for i in range(n - 1):
	if b == t:
		print('YES')
		break
	elif b > t:
		print('NO')
		break
	else:
		b += a[b - 1]


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
can = [0 for _ in range(n)]
can[0] = 1
for i in range(n - 1):
	if can[i]:
		can[i + a[i]] = 1
print('YES' if can[t - 1] else 'NO')


(n, t) = map(int, input().split())
l = list(map(int, input().split()))
i = 0
YES = 0
while i in range(0, n - 1):
	a = l[i]
	i += a
	if i + 1 == t:
		YES += 1
		break
if YES == 1:
	print('YES')
else:
	print('NO')


a = lambda : map(int, input().split())
(n, m) = a()
b = list(a())
c = 0
while c < m - 1:
	c += b[c]
print('YNEOS'[c >= m::2])


(n, t) = map(int, input().strip().split(' '))
arr = list(map(int, input().strip().split(' ')))
found = arr[0]
done = False
while found < t:
	if found == t - 1:
		print('YES')
		done = True
		break
	found += arr[found]
if not done:
	print('NO')


q = input().split()
n = int(q[0])
t = int(q[1])
a = input().split()
x = 0
while x < len(a):
	a[x] = int(a[x])
	x = x + 1
x = 0
y = 1
z = [1]
b = 0
while x < len(a):
	b = a[x] + y
	z.append(b)
	x = b - 1
	y = x + 1
if t in z:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
a.append(1)
i = 0
while i < n:
	if i + 1 == t:
		print('YES')
		exit()
	i += a[i]
print('NO')


import os
import sys
from math import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def array():
	return [int(i) for i in input().split()]
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def bfs(adj, s, vis):
	q = []
	q.append(s)
	vis[s] = True
	while q != []:
		ele = q.pop(0)
		for i in adj[ele]:
			if vis[i] == False:
				vis[i] = True
				q.append(i)
(n, s) = map(int, input().split())
a = array()
adj = {i: [] for i in range(1, n + 1)}
for i in range(n - 1):
	adj[i + 1].append(a[i] + i + 1)
vis = {i: False for i in adj.keys()}
bfs(adj, 1, vis)
if vis[s] == True:
	print('YES')
else:
	print('NO')


(a, l, b) = (int(input().split()[1]), list(map(int, input().split())), 1)
while b < a:
	b += l[b - 1]
print('YNEOS'[b > a::2])


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
p = 0
while p < m - 1:
	p += a[p]
if p == m - 1:
	print('YES')
else:
	print('NO')


(n, t) = [int(x) for x in input().split()]
a = [0] + [int(x) for x in input().split()]
x = 1
y = 0
while x <= t:
	x += a[x]
	if x == t:
		y = 1
		break
if y == 1:
	print('YES')
else:
	print('NO')


import sys
from collections import defaultdict
mod = 1000000007

def get_array():
	return list(map(int, sys.stdin.readline().split()))

def get_ints():
	return map(int, sys.stdin.readline().split())

def input():
	return sys.stdin.readline()

def print_array(a):
	print(' '.join(map(str, a)))

class Graph:

	def __init__(self):
		self.graph = defaultdict(list)

	def addEdge(self, u, v):
		self.graph[u].append(v)

	def traverse(self, n, fr, to):
		q = []
		q.append(self.graph[fr])
		while q:
			e = q.pop(0)
			if to in e:
				return True
			for x in e:
				q.append(self.graph[x])
		return False

def main():
	(n, s) = get_ints()
	a = get_array()
	routes = Graph()
	for i in range(1, n):
		routes.addEdge(i, i + a[i - 1])
	print('YES' if routes.traverse(n, 1, s) else 'NO')
main()


(n, t) = [int(i) for i in input().split()]
ar = [int(i) for i in input().split()]
ar.insert(0, 0)
ar.append(1)
i = 1
while i <= n:
	if i == t:
		print('YES')
		exit(0)
	i += ar[i]
print('NO')


(m, n) = map(int, input().split())
l = list(map(int, input().split()))
ans = []
sum = 1
while sum < n:
	sum += l[sum - 1]
if sum == n:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
ni = [0]
ni.extend(map(int, input().split()))
x = 1
while x < t:
	x += ni[x]
if x == t:
	print('YES')
else:
	print('NO')


(n, p) = map(int, input().split())
x = [int(i) for i in input().split()]
ind = 1
flag = 0
while ind <= p:
	ind += x[ind - 1]
	if ind == p:
		print('YES')
		flag = 1
		break
if flag == 0:
	print('NO')


(n, t) = map(int, input().split())
l = list(map(int, input().split()))
c = 1
x = 'NO'
while c < t:
	c += l[c - 1]
	if c == t:
		x = 'Yes'
		break
print(x)


(n, t) = [int(x) for x in input().split()]
e = 0
y = 0
l = [int(v) for v in input().split()]
for a in range(0, n - 1):
	k = l[y] + y + 1
	if k == t:
		print('YES')
		break
	elif k > t:
		print('NO')
		break
	y = k - 1


x = lambda : map(int, input().split())
(n, t) = x()
(a, i) = (list(x()), 1)
while i < t:
	i += a[i - 1]
print('NYOE S'[i == t::2])


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
p = 1
while True:
	if p == t:
		print('YES')
		break
	if p > t:
		print('NO')
		break
	p += a[p - 1]


(n, m) = map(int, input().split())
l = [0]
l = l + list(map(int, input().split()))
i = 1
f = 1
if m == 1:
	print('YES')
	f = 2
else:
	while i <= m:
		i = l[i] + i
		if i == m:
			f = 0
			break
if f == 0:
	print('YES')
elif f == 1:
	print('NO')


(n, t) = map(int, input().split())
l = list(map(int, input().split()))
pos = 1
while True:
	pos += l[pos - 1]
	if pos == t:
		print('YES')
		break
	elif pos > t:
		print('NO')
		break


(n, t) = map(int, input().split())
port = list(map(int, input().split()))
pos = 1
while pos < t and pos <= n:
	pos = pos + port[pos - 1]
if pos == t:
	print('YES')
else:
	print('NO')


import sys
(a, b) = input().split()
arr = list(map(int, input().split()))
m = 1
while m < int(a):
	m = m + arr[m - 1]
	if m == int(b):
		print('YES')
		sys.exit()
if m == int(b):
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
a.insert(0, 0)
position = 1
while position < t:
	position += a[position]
	if position == t:
		print('YES')
		break
	if position > t:
		print('NO')
		break


(n, t) = map(int, input().split())
lis = list(map(int, input().split()))
k = True
i = 1
while k:
	i = i + lis[i - 1]
	if i == t:
		k = False
	elif i >= n:
		break
print(('YES', 'NO')[k])


(n, t) = input().strip().split(' ')
n = int(n)
t = int(t)
t -= 1
a = input().strip().split(' ')
for i in range(0, n - 1):
	a[i] = int(a[i])
	i += 1
x = 0
fleg = 0
while x < n - 1:
	x = x + a[x]
	if x == t:
		fleg = 1
if fleg == 0:
	print('NO\n')
else:
	print('YES\n')


(a, b) = map(int, input().split())
lst = list(map(int, input().split()))
cost = 1
while cost < b:
	cost += lst[cost - 1]
if cost == b:
	print('YES')
else:
	print('NO')


def solve():
	rdl = list(map(int, input().split()))
	(n, t) = rdl
	rdl = list(map(int, input().split()))
	curindex = 0
	can = False
	for i in range(n):
		curindex += rdl[curindex]
		if t - 1 == curindex:
			can = True
			print('YES')
			break
		if curindex > t - 1:
			break
	if not can:
		print('NO')
solve()


def init():
	(num_cells, dest) = map(lambda x: int(x), input().split(' '))
	cells = list(map(lambda x: int(x), input().split(' ')))
	cells.append(1)
	i = 0
	while i < num_cells:
		if i + 1 == dest:
			print('YES')
			return
		else:
			i += cells[i]
	print('NO')
init()


(_, t) = map(int, input().split())
cs = list(map(int, input().split()))
a = 1
while a < t:
	a = a + cs[a - 1]
print('YES' if a == t else 'NO')


l = input().split()
p = input().split()
d = int(l[0])
a = [1]
b = int(l[1])
c = 0
i = 1
while i < d:
	c = i + int(p[i - 1])
	a.append(c)
	i = c
if b in a:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
c = 1
while c <= n:
	if c == m:
		print('YES')
		break
	elif c == n:
		print('NO')
		break
	c = c + l[c - 1]


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	(n, m) = LI()
	a = LI()
	c = 0
	while c < n - 1:
		c += a[c]
		if c == m - 1:
			return 'YES'
	return 'NO'
print(main())


(a, b) = map(int, input().split())
c = list(map(int, input().split()))
i = 1
d = 0
while i <= b:
	if i == b:
		print('YES')
		d = 1
		break
	i += c[i - 1]
if d == 0:
	print('NO')


x = int(input().split()[1]) - 1
a = list(map(int, input().split()))
c = 0
while c < x:
	c += a[c]
print(('NO', 'YES')[c == x])


(n, p) = map(int, input().split())
a = list(map(int, input().split()))
ans = []
i = 0
while i < n:
	if i == p - 1:
		print('YES')
		exit()
	try:
		i += a[i]
	except:
		break
print('NO')


def solve():
	(n, t) = map(int, input().strip().split())
	a = list(map(int, input().strip().split()))
	a.append(1)
	t -= 1
	currentPos = 0
	while currentPos < n:
		if currentPos == t:
			print('YES')
			return
		else:
			currentPos += a[currentPos]
	print('NO')
solve()


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
index = 1
while index < n:
	if index == t:
		break
	else:
		index += a[index - 1]
if index == t:
	print('YES')
else:
	print('NO')


(n, dest) = input().split()
n = int(n)
dest = int(dest)
x = input().split()
for i in range(n - 1):
	x[i] = int(x[i])
curr = 0
for i in range(n - 1):
	if curr == dest - 1:
		print('YES')
		exit()
	if curr > n - 2:
		print('NO')
		exit()
	curr = curr + x[curr]
if curr == dest - 1:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
a = map(int, input().split())
p = 1
i = 1
for d in a:
	if i == p:
		p += d
		if p >= m:
			print('YES' if p == m else 'NO')
			break
	i += 1


def f(i):
	while i < t:
		i += a[i - 1]
	return 'YNEOS'[i != t::2]
x = input('').split()
n = int(x[0])
t = int(x[1])
a = []
for i in range(999):
	a.append(1)
a = input('').split()
a = list(map(int, a))
print(f(1))


(a, b) = map(int, input().split())
lst = list(map(int, input().split()))
lst2 = []
i = 0
while i < a - 1:
	i += lst[i]
	lst2.append(i + 1)
if b in lst2:
	print('YES')
else:
	print('NO')


(n, m) = tuple(map(int, input().split()))
line = list(map(int, input().split()))
i = 0
while i < m - 1:
	i = i + line[i]
if i == m - 1:
	print('YES')
else:
	print('NO')


(z, zz) = (input, lambda : list(map(int, z().split())))
zzz = lambda : [int(i) for i in stdin.readline().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
(n, m) = zz()
l = [0] + zzz()
i = 1
while i < m:
	i += l[i]
print('YES' if i == m else 'NO')


I = lambda : [int(i) for i in input().split()]
(n, t) = I()
a = []
a = I()
c = 0
while c < t - 1:
	c = c + a[c]
if c >= t:
	print('NO')
else:
	print('YES')


def getThere(n, t, cells):
	pos = 1
	while pos < n:
		if pos < n:
			pos += cells[pos - 1]
		if pos == t:
			return 'YES'
	return 'NO'
[n, t] = [int(x) for x in input().split()]
cells = [int(x) for x in input().split()]
print(getThere(n, t, cells))


def ans(t, bt):
	i = 1
	nexthop = -1
	while i <= n:
		nexthop = i + bt[i - 1]
		if nexthop == t:
			return 'YES'
		if nexthop > t:
			return 'NO'
		i = nexthop
(n, t) = map(int, input().split())
bt = list(map(int, input().split()))
print(ans(t, bt))


(t, a, s) = (int(input().split()[1]) - 1, list(map(int, input().split())), 0)
while s < t:
	s += a[s]
print('YNEOS'[s > t::2])


(n, m) = list(map(int, input().split(' ')))
indexes = list(map(int, input().split(' ')))
index = int(1)
while index < m:
	index += indexes[index - int(1)]
if index == m:
	print('YES')
else:
	print('NO')


inStr = input()
n = int(inStr.split()[0])
t = int(inStr.split()[1])
graph = {}
inStr = input()
for (i, a) in enumerate(inStr.split()):
	graph[i + 1] = i + 1 + int(a)

def dfs(graph, start, goal):
	stack = [start]
	while stack:
		vertex = stack.pop()
		if vertex == goal:
			return 'YES'
		if vertex in graph:
			next = graph[vertex]
			stack.append(next)
	return 'NO'
print(dfs(graph, 1, t))


(a, b) = map(int, input().split())
arr = list(map(int, input().split()))
i = 1
while i < a:
	arr[i - 1] = arr[i - 1] + i
	i = arr[i - 1]
	if i == b:
		print('YES')
		exit()
print('NO')


(n, t) = list(map(int, input().rstrip().split()))
cells = list(map(int, input().rstrip().split()))
visit = 0
visited = [1]
can_reach = False
while visit < n - 1:
	visited.append(visited[-1] + cells[visit])
	visit = visit + cells[visit]
	if visit + 1 == t:
		can_reach = True
		break
	if visit + 1 > t:
		break
if can_reach:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
i = 0
while True:
	if i == t - 1:
		print('YES')
		break
	elif i > t or i > n - 2:
		print('NO')
		break
	i += a[i]


(n, t) = map(int, input().split())
cells = list(map(int, input().split()))
i = 1
while i < n:
	i += cells[i - 1]
	if i == t:
		print('YES')
		break
	elif i > t:
		print('NO')
		break


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
b = [True] + [False for _ in range(n - 1)]
for i in range(n - 1):
	if b[i]:
		b[a[i] + i] = True
print('YES' if b[t - 1] else 'NO')


nums = [int(i) for i in input().split()]
nCells = nums[0]
dest = nums[1]
nums = [int(i) for i in input().split()]
currCell = 1
while currCell <= len(nums):
	currCell = nums[currCell - 1] + currCell
	if currCell == dest:
		print('YES')
		exit()
print('NO')


(n, v) = list(map(int, input().split()))
vals = list(map(int, input().split()))
vals = [-1] + vals
index = 1
found = False
index = 1
while index < len(vals):
	if index == v:
		found = True
		break
	if index > v:
		break
	index += vals[index]
if index == v:
	found = True
if found:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
r = 1
while True:
	if r >= n:
		print('NO')
		quit()
	r += a[r - 1]
	if r == t:
		print('YES')
		quit()


(n, t) = map(int, input().split())
l = list(map(int, input().split()))
transport = 1
while transport < t:
	transport = transport + l[transport - 1]
if transport == t:
	print('YES')
else:
	print('NO')


(n, index) = list(map(int, input().split()))
stations = list(map(int, input().split()))
i = 1
while i < index:
	i += stations[i - 1]
if i == index:
	print('YES')
else:
	print('NO')


a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = 0
while x < a[1]:
	if x + 1 == a[1]:
		print('YES')
		break
	x += b[x]
else:
	print('NO')


(n, t) = map(int, input().split())
l = list(map(int, input().split()))
L = [0] + l
p = 1
while 1:
	if p == t:
		print('YES')
		break
	if p > t:
		print('NO')
		break
	else:
		p += L[p]


vars = input().split()
n = int(vars[0])
t = int(vars[1])
numbers = input().split()
for i in range(len(numbers)):
	numbers[i] = int(numbers[i])
target = 1
while target < t:
	target += numbers[target - 1]
if target == t:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
i = 1
c = 0
k = 0
while k < m:
	k = i + a[i - 1]
	i = k
	if k == m:
		c = 1
		break
if c == 1:
	print('YES')
else:
	print('NO')


import sys
sys.setrecursionlimit(150000)
(n, t) = map(int, input().split())
l = list(map(int, input().split()))
hash_g = {}
hash_dis = {}
for i in range(1, n + 1):
	hash_g[i] = set()
	hash_dis[i] = False
for i in range(1, n):
	if i + l[i - 1] <= n:
		hash_g[i].add(i + l[i - 1])
stack = [1]
hash_dis[1] = True
while stack != []:
	u = stack.pop()
	for i in hash_g[u]:
		if hash_dis[i] == False:
			hash_dis[i] = True
			stack.append(i)
if hash_dis[t] == True:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
l1 = [0]
l = list(map(int, input().split()))
l1.extend(l)
flag = 0
s = 1
for i in range(1, n + 1):
	s = s + l1[s]
	if s == t:
		flag = 1
		break
	if s > t:
		break
if flag == 1:
	print('YES')
else:
	print('NO')


def main():
	(n, t) = map(int, input().split())
	listNumbers = list(map(int, input().split()))
	jumps = 1
	out = 0
	while jumps < n and out == 0:
		jumps += listNumbers[jumps - 1]
		if jumps == t:
			print('YES')
			out = 1
		elif jumps > t:
			print('NO')
			out = 1
main()


(n, t) = map(int, input().split())
a = [int(i) for i in input().split()]
i = 0
while i <= n - 2:
	i += a[i]
	if i + 1 == t:
		print('YES')
		exit()
print('NO')


line = input().split()
(n, t) = (int(line[0]), int(line[1]))
t -= 1
line = input().split()
current = 0
while current < t:
	current += int(line[current])
if current == t:
	print('YES')
else:
	print('NO')


from collections import deque
from collections import OrderedDict
import math
import sys
import os
import threading
import bisect
import operator
import heapq
from atexit import register
from io import BytesIO
import io
input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, m) = map(int, input().split())
ar = [0] + list(map(int, input().split()))
idx = 1
while idx <= n:
	idx += ar[idx]
	if idx == m:
		print('YES')
		break
	elif idx > m:
		print('NO')
		break


(a, b) = map(int, input().split())
l = list(map(int, input().split()))
tmp = 1
while tmp < b:
	tmp = tmp + l[tmp - 1]
if tmp == b:
	print('YES')
else:
	print('NO')


inp = input()
num_of_cells = inp.split(' ')
destination = int(num_of_cells[1])
num_of_cells = int(num_of_cells[0])
numbers = input()
numbers = numbers.split(' ')
for i in range(len(numbers)):
	numbers[i] = int(numbers[i])
current_position = 1
success = False
while current_position <= destination:
	if current_position == destination:
		success = True
		break
	else:
		current_position += numbers[current_position - 1]
if success:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
cell = [0] * (2 + n)
x = list(map(int, input().split()))
for i in range(1, n):
	cell[i] = x[i - 1]
visited = [False] * (2 + n)
currIndex = 1
while currIndex != t and visited[currIndex] == False:
	nextIndex = currIndex + cell[currIndex]
	visited[currIndex] = True
	currIndex = nextIndex
if currIndex == t:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
l = list(map(int, input().split()))
l = [0] + l
i = 1
while i < t:
	i += l[i]
print('Yes' if i == t else 'No')


import sys
input = sys.stdin.readline
ins = lambda : input().rstrip()
ini = lambda : int(input().rstrip())
inm = lambda : map(int, input().rstrip().split())
inl = lambda : list(map(int, input().split()))
out = lambda x, s='\n': print(s.join(map(str, x)))
(n, t) = inm()
a = inl()
ans = False
i = 0
while True:
	if i > t - 1:
		ans = False
		break
	if i == t - 1:
		ans = True
		break
	i += a[i]
print('YES' if ans else 'NO')


(n, t) = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
res = [False] * n
old = 1
flag = False
while res[old - 1] == False:
	res[old - 1] = True
	if old == n:
		break
	old += x[old - 1]
	if old == t:
		flag = True
		break
if flag:
	print('YES')
else:
	print('NO')


from sys import stdin
import collections
(n, t) = map(int, stdin.readline().rstrip().split(' '))
port = list(map(int, stdin.readline().rstrip().split(' ')))
cur = 1
if cur == t:
	print('YES')
	exit()
while cur < n:
	cur = port[cur - 1] + cur
	if cur == t:
		print('YES')
		exit()
if cur == t:
	print('YES')
else:
	print('NO')


from collections import defaultdict
(n, t) = map(int, input().split())
a = list(map(int, input().split()))
d = {}
for i in range(n - 1):
	d[i] = a[i] + i
i = 0
while i < n - 1:
	if i == t - 1:
		break
	i = d[i]
if i == t - 1:
	print('YES')
else:
	print('NO')


(a, b) = map(int, input().split())
l = list(map(int, input().split()))
ans = 0
now = 0
boo = True
for i in range(a - 1):
	if boo:
		ans = i + 1
		now = l[i]
		boo = False
	now -= 1
	if now == 0:
		boo = True
	if ans >= b:
		break
print('YES' if b == ans or a == b else 'NO')


import math, fractions, collections
(n, t) = [int(x) for x in input().split()]
q = [int(x) for x in input().split()]
current = 1
flag = 0
while current < n:
	current += q[current - 1]
	if current == t:
		flag = 1
		break
print('YES' if flag else 'NO')


(n, k) = list(map(int, input().split(' ')))
portals = list(map(int, input().split(' ')))
flag = 0
i = 1
while i < n:
	if i + portals[i - 1] == k:
		print('YES')
		flag = 1
		break
	else:
		i = i + portals[i - 1]
if flag == 0:
	print('NO')


(n, t) = map(int, input().split())
count = 0
y = [0] * 30000
y[1:] = list(map(int, input().split()))
i = 1
while i != t:
	i = y[i] + i
	if i == t:
		count = 1
		break
	if i > n - 1:
		break
if count == 1:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
a.append(1)
cur = 1
flag = 0
i = 1
while i <= n - 1:
	i += a[i - 1]
	if i == t:
		flag = 1
		break
if flag == 1:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().strip().split())
L = {}
for (i, a) in enumerate(input().strip().split()):
	L[i + 1] = int(a)
x = 1
e = 0
while x < m:
	x = x + L[x]
if x == m:
	print('YES')
else:
	print('NO')


__author__ = 'catman'
(n, t) = map(int, input().split())
a = list(map(int, input().split()))
i = 1
while True:
	if i == t:
		found = True
		break
	elif i > t:
		found = False
		break
	i += a[i - 1]
if found:
	print('YES')
else:
	print('NO')


(_, target) = [int(x) for x in input().strip().split()]
list_p = [int(x) for x in input().strip().split()]
(current, target) = (0, target - 1)
while current <= target:
	current += list_p[current]
	if current == target:
		print('YES')
		break
else:
	print('NO')


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
v = []
i = 0
while i <= n - 1:
	v.append(i + 1)
	if i == n - 1:
		break
	elif i < n - 1:
		i += a[i]
print(['NO', 'YES'][t in v])


b = int(input().split()[1])
f = [0] + [int(x) for x in input().split()]
i = 1
while i < b:
	i = i + f[i]
	if i == b:
		print('YES')
		quit()
print('NO')


(n, t) = list(map(int, input().split()))
A = list(map(int, input().split()))
socket = 1
while socket <= t:
	socket += A[socket - 1]
	if socket > t:
		print('NO')
		break
	elif socket == t:
		print('YES')
		break


class AdjacencyList:

	def __init__(self, *a):
		if len(a) == 1:
			v = a[0].vertices()
			e = a[0].edges()
		else:
			v = a[0]
			e = a[1]
		self.m = len(e)
		self.v = [0] * v if type(v) == int else v
		self.n = len(self.v)
		self.e = [[] for i in range(self.n)]
		for i in e:
			self.e[i[0]] += [i]

	def vertices(self):
		return self.v

	def edges(self):
		return [j for i in range(self.n) for j in self.e[i]]

	def outgoing_edges(self, v):
		return self.e[v]

	def incoming_edges(self, v):
		return [j for i in range(self.n) for j in self.e[i] if j[1] == v]

	def add_edge(self, e):
		self.e[e[0]] += [e]

	def remove_edge(self, e):
		self.e[e[0]] = [i for i in self.e[e[0]] if i != e]

def read_line(*a):
	r = input().split()
	for i in range(len(r)):
		r[i] = a[min(i, len(a) - 1)](r[i])
	return r

def reachable_vertices(g, v, f=[]):
	s = [v]
	if f == []:
		f = [0] * g.n
	r = []
	while s:
		u = s[-1]
		s.pop(-1)
		if f[u] == 1:
			continue
		r.append(u)
		f[u] = 1
		for e in g.outgoing_edges(u):
			s.append(e[1])
	return r
Graph = AdjacencyList
(n, t) = read_line(int)
a = read_line(int)
g = Graph(n, [])
for i in range(n - 1):
	g.add_edge((i, i + a[i]))
print('YES' if reachable_vertices(g, 0).count(t - 1) else 'NO')


(n, dest) = map(int, input().split())
portal = list(map(int, input().split()))
index = 1
isseen = False
while index <= n:
	if index == dest:
		isseen = True
		break
	try:
		index += portal[index - 1]
	except:
		break
if isseen:
	print('YES')
else:
	print('NO')


(n, t) = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]
c = 1
while c != n and c != t:
	c += a[c - 1]
else:
	if c == t:
		print('YES')
	else:
		print('NO')


(n, target) = [int(x.strip()) for x in input().split()]
target -= 1
cells = [int(x.strip()) for x in input().split()]
for i in range(len(cells)):
	cells[i] = cells[i] + i
start = 0
visited = set([0])
result = 'NO'
queue = [0]

def bfs(target):
	global queue
	while len(queue) > 0:
		start = queue[0]
		queue = queue[1:]
		if start == target:
			global result
			result = 'YES'
			return
		if start == n - 1:
			return
		if cells[start] not in visited:
			visited.add(cells[start])
			queue.append(cells[start])
	return
bfs(target)
print(result)


import os
import sys
from io import BytesIO, IOBase

def main():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = 'NO'
	z = 1
	while True:
		z = z + a[z - 1]
		if z == k:
			ans = 'YES'
			break
		elif z > k:
			break
	print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import math
import bisect
(n, target) = map(int, input().split())
a = list(map(int, input().split()))
i = 1
while i < target:
	i = i + a[i - 1]
if i == target:
	print('YES')
else:
	print('NO')


(n, dest) = map(int, input().strip().split())
edges = list(map(int, input().strip().split()))
curr = 1
ans = False
for i in range(n):
	if curr == dest:
		ans = True
		break
	try:
		curr += edges[curr - 1]
	except:
		break
print('YES') if ans else print('NO')


a = input()
a = a.split(' ')
n = int(a[0])
t = int(a[1])
a = input()
a = a.split(' ')
i = 0
while i < t - 1:
	i += int(a[i])
if i == t - 1:
	print('YES')
else:
	print('NO')


from array import array
(n, t) = map(int, input().split())
a = array('i', map(int, input().split()))
b = array('i', [1])
s = 1
while s < n:
	try:
		s = s + a[s - 1]
		b.append(s)
	except IndexError:
		break
print('NYOE S'[t in b::2])


a = input().split()
b = input().split()
t = int(a[1])
for (i, x) in enumerate(b):
	b[i] = int(b[i])
i = 0
while i < len(b):
	i += b[i]
	if i + 1 == t:
		print('YES')
		break
else:
	print('NO')


(n, t) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = 0
c = 1
while b < t and c < n:
	b = c + a[c - 1]
	c = b
if b == t:
	print('YES')
else:
	print('NO')


def search(portals, src, dest):
	visited = set()
	while src not in visited:
		if src == dest - 1:
			return 'YES'
		visited.add(src)
		src = src + portals[src]
	return 'NO'

def main():
	dest = int(input().split(' ')[1])
	portals = [int(x) for x in input().split(' ')]
	portals.append(0)
	print(search(portals, 0, dest))
main()


def dfs(node):
	visited[node] = 1
	stack = [node]
	while len(stack):
		try:
			curr = stack[-1]
			stack.pop(-1)
			visited[adj_list[curr]] = 1
			stack.append(adj_list[curr])
		except:
			pass
(n, t) = map(int, input().split())
arr = list(map(int, input().split()))
adj_list = dict()
i = 0
while i < n - 1:
	adj_list[i + 1] = arr[i] + (i + 1)
	i += 1
visited = [0] * (n + 1)
dfs(1)
if visited[t]:
	print('YES')
else:
	print('NO')


(X, Standing) = (list(map(int, input().split())), 1)
Portal = list(map(int, input().split()))
while Standing <= X[1]:
	if Standing == X[1]:
		print('YES')
		exit()
	Standing += Portal[Standing - 1]
print('NO')


(n, t) = map(int, input().split())
portals = list(map(int, input().split()))
ans = False
i = 1
while i < n:
	index = i - 1
	step = portals[index]
	if i + step == t:
		ans = True
		break
	elif i + step > t:
		ans = False
		break
	else:
		i = i + step
if ans:
	print('YES')
else:
	print('NO')


(n, ind) = map(int, input().split())
a = input().split()
b = []
for i in range(len(a)):
	b.append(i + 1 + int(a[i]))
y = False
c = 1
while c != n:
	c = b[c - 1]
	if c == ind:
		y = True
		break
if y:
	print('Yes')
else:
	print('NO')


(n, t) = map(int, input().split())
lineworld = list(map(int, input().split()))
place = 1
while place < t:
	place += lineworld[place - 1]
if place == t:
	print('YES')
else:
	print('NO')


[x, y] = [int(i) for i in input().split()]
z = [int(i) for i in input().split()]
s = 1
while s < y:
	s = s + z[s - 1]
if s == y and y <= x:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
t -= 1
a = list(map(int, input().split()))

def dfs(v):
	current = v
	while current < t and current < n - 1:
		current = current + a[current]
	if current == t:
		return True
	return False
result = dfs(0)
if result:
	print('YES')
else:
	print('NO')


(alen, end) = list(map(int, input().split()))
a = list(map(int, input().split()))
flag = False
ai = 1
while ai < alen:
	next = ai + a[ai - 1]
	if next == end:
		print('YES')
		flag = True
		break
	ai = next
if not flag:
	print('NO')


(n, goal) = map(int, input().split())
cells = [int(x) for x in input().split()]
i = 0
possible = False
while True:
	if i + 1 == goal:
		possible = True
		break
	elif i + 1 > goal:
		break
	else:
		i += cells[i]
if possible:
	print('YES')
else:
	print('NO')


(n, t) = input().rsplit(' ')
(n, t) = (int(n), int(t))
lineWorld = [int(x) for x in input().rsplit(' ')]
start = 1
while start < t and start < n:
	oldStart = start
	start += lineWorld[start - 1]
	if start == oldStart:
		break
if start == t:
	print('YES')
else:
	print('NO')


import sys

def main():
	(n, t) = tuple([int(y) for y in input().split()])
	a = [int(x) for x in input().split()]
	c = 1
	while True:
		c = c + a[c - 1]
		if c == t:
			print('YES')
			sys.exit()
		elif c > t:
			print('NO')
			sys.exit()
	print('NO')
main()


input1 = input().split(' ')
portals = input().split(' ')
n = int(input1[0]) - 1
t = int(input1[1]) - 1
visit = 0
i = 0
while visit < t:
	visit += int(portals[i])
	i = visit
if visit == t:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
arr = [int(i) for i in input().split()]
found = False
i = 0
while i < len(arr) and arr[i] + i + 1 <= t:
	destination = arr[i] + i + 1
	if destination == t:
		found = True
		i = 999999
	elif destination > t:
		i = 999999
	else:
		i = destination - 1
print(['NO', 'YES'][found])


k = int(input().split()[1])
m = list(map(int, input().split()))
j = 1
while j < k:
	j += m[j - 1]
if k == j:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
t -= 1
i = 0
while True:
	if i == t:
		print('YES')
		exit()
	if i >= len(a):
		break
	i += a[i]
print('NO')


(n, t) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
seq = []
current = 1
while current <= n - 1:
	seq.append(current)
	current += a[current - 1]
	if current == n:
		seq.append(current)
if t in seq:
	print('YES')
else:
	print('NO')


(n, t) = [int(c) for c in input().split()]
vetor = [int(c) for c in input().split()]
cell = 1
while cell < t:
	cell += vetor[cell - 1]
if cell == t:
	print('YES')
else:
	print('NO')


import re
input_list = re.findall('\\d+', input())
n = int(input_list[0])
t = int(input_list[1])
a_list = re.findall('\\d+', input())
is_visited = [1]
i = 0
while True:
	try:
		i = i + 1 + int(a_list[i])
		if i == t:
			break
		i -= 1
	except IndexError:
		print('NO')
		raise exit()
print('YES')


I = lambda : map(int, input().split())
(n, m) = I()
a = list(I())
cell = 1
while cell < m:
	cell += a[cell - 1]
print('YES' if cell == m else 'NO')


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
visited = [False for i in range(n)]
t = t - 1
cn = 0
visited[0] = True
while True:
	if cn == t:
		print('YES')
		break
	if cn == n - 1:
		print('NO')
		break
	cn = cn + a[cn]
	if visited[cn]:
		print('NO')
		break
	else:
		visited[cn] = True


inp = [int(n) for n in input().split()]
(cells, dest) = (inp[0], inp[1])
nums = [int(a) for a in input().split()]
found = 'NO'
tot = 1
while tot < cells:
	if tot == 1:
		i = 1
		a = nums[0]
		tot = i + a
	else:
		i = tot
		a = nums[i - 1]
		tot = i + a
	if tot == dest:
		found = 'YES'
print(found)


(_, n) = [int(x) for x in input().split(' ')]
a = [int(x) for x in input().split(' ')]
n -= 1
c = 0
while c < n:
	c += a[c]
print('YES' if c == n else 'NO')


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
t = 1
g = 'YES'
while True:
	if t > k:
		g = 'NO'
		break
	if t == k:
		g = 'YES'
		break
	t = l[t - 1] + t
print(g)


(n, t) = list(map(int, input().split(' ')))
a = list(map(int, input().split(' ')))
(i, b) = (0, False)
while i < t:
	i += a[i]
	if i + 1 == t:
		b = True
		break
if b:
	print('YES')
else:
	print('NO')


import sys
(n, t) = map(int, sys.stdin.readline().split())
alist = list(map(int, sys.stdin.readline().split()))
crt = 1
while crt < t:
	crt += alist[crt - 1]
if crt == t:
	print('YES')
else:
	print('NO')


(n, l) = input().split()
a = input().split()
a = [int(i) for i in a]
n = int(n)
l = int(l)
inde = 1
while inde < n and inde != l:
	inde = a[inde - 1] + inde
if inde != l:
	print('NO')
else:
	print('YES')


def main():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	flag = False
	i = 1
	ctr = 0
	while i <= k:
		if i == k:
			flag = True
			break
		i = i + a[i - 1]
	if flag:
		print('YES')
	else:
		print('NO')
main()


(n, t) = [int(_) for _ in input().split()]
a = [0] + [int(_) for _ in input().split()]
i = 1
while i < len(a):
	i += a[i]
	if i == t:
		print('YES')
		exit()
print('NO')


(n, t) = map(int, input().split())
(a, i) = ([int(x) for x in input().split()], 1)
while i < t:
	i += a[i - 1]
print('NYOE S'[i == t::2])


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
i = 1
while i < t and i < n:
	i += a[i - 1]
if i == t:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split(' '))
ls = list(map(int, input().split(' ')))
flag = 0
i = 0
while i < len(ls):
	if i + 1 + ls[i] == t:
		print('YES')
		flag = 1
	i = i + 1 + ls[i] - 1
if flag == 0:
	print('NO')


(n, t) = map(int, input().split())
a = [int(x) for x in input().split()]
b = 1
while b < t:
	b = b + a[b - 1]
if b == t:
	print('YES')
elif b > t:
	print('NO')


(n, t) = list(map(int, input().split(' ')))
x = list(map(int, input().split(' ')))
i = 1
while i <= t:
	if i == t:
		print('YES')
		exit()
	i = i + x[i - 1]
print('NO')


(a, b) = map(int, input().split())
l = list(map(int, input().split()))
p = 1
i = 0
while p < b:
	p = p + l[i]
	i += l[i]
	if p == b:
		print('YES')
		break
else:
	print('NO')


(n, t) = map(int, input().split())
arr = list(map(int, input().split()))
visit = [1]
i = 1
while i < n:
	x = i + arr[i - 1]
	i = x
	visit.append(x)
if t in visit:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
x = map(int, input().split())
y = list(x)
i = 1
v = [1]
while i < n:
	v.append(i + y[i - 1])
	i += y[i - 1]
if m in v:
	print('YES')
else:
	print('NO')


from collections import deque

def check(something, target):
	return something == target
(tot, target) = input().split(' ')
target = int(target)
tot = int(tot)
cells = list(map(int, input().split(' ')))
search_queue = deque()
graph = {}
i = 1
while i <= tot - 1:
	graph[i] = [i + cells[i - 1]]
	i += 1
search_queue += graph[1]
y = 0
gotit = False
while len(search_queue) != 0:
	y += 1
	elem = search_queue.popleft()
	checks = check(elem, target)
	if checks:
		print('YES')
		gotit = True
		break
	else:
		if elem > len(graph):
			break
		search_queue += graph[elem]
if not gotit:
	print('NO')


(n, t) = map(int, input().split())
arr = [int(x) for x in input().split()]
start = 1
while start < t and start >= 0:
	start = start + arr[start - 1]
print('YES' if start == t else 'NO')


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
i = 1
while i < k + 1:
	i = i + a[i - 1]
	if i == k:
		print('YES')
		break
if i >= k + 1:
	print('NO')


(n, t) = input().split()
n = int(n)
t = int(t)
a = input().split()
l = []
for i in range(len(a)):
	l.append(int(a[i]))
res = 1
flag = False
while res <= t:
	if res == t:
		flag = True
		break
	else:
		res = res + l[res - 1]
if flag == False:
	print('NO')
else:
	print('YES')


(cell_n, togo) = map(int, input().split())
trans = list(map(int, input().split()))
i = 0
while i < togo - 1:
	i += trans[i]
print('YES' if i == togo - 1 else 'NO')


success = False
line1 = input()
(n, t) = list(map(int, line1.split()))
line2 = input()
a = [0] + list(map(int, line2.split()))
i = 1
while i < n and i != t:
	i += a[i]
if i == t:
	print('YES')
else:
	print('NO')


from sys import stdin
i = [[int(y) for y in x.rstrip().split()] for x in stdin.readlines()]
goal = i[0][1] - 1
t = i[1]
c = 0
while goal > 0:
	goal -= t[c]
	c += t[c]
print(('NO', 'YES')[goal == 0])


(t, k) = map(int, input().split())
l = input().split()
l = [int(x) for x in l]
l1 = [m + 1 for m in range(len(l))]
l2 = [1 + i + l[i] for i in range(len(l))]
d = dict(zip(l1, l2))
_ = 1
ac = 0
while _ <= len(l2):
	if d[_] == k:
		ac = 0
		break
	else:
		_ = d[_]
		ac += 1
if ac == 0:
	print('YES')
else:
	print('NO')


s = input()
n1 = [int(i) for i in s.split()]
n = n1[0]
t = n1[1]
s = input()
n2 = [0] + [int(i) for i in s.split()]
i = 1
found = 0
while i <= n:
	if i == t:
		found = 1
		break
	elif i > t:
		break
	else:
		i += n2[i]
if found == 0:
	print('NO')
else:
	print('YES')


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
result = 0
for i in range(n - 1):
	if result == i:
		result += a[i]
	else:
		continue
	if result == t - 1:
		print('YES')
		break
else:
	print('NO')


(n, t) = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]
i = 1
while True:
	if i == t:
		print('YES')
		break
	if i >= n:
		print('NO')
		break
	i = l[i - 1] + i


(n, t) = map(int, input().split())
line = [int(x) for x in input().split()]
c = True
x = 0
while c:
	if x >= len(line):
		c = False
		print('NO')
	else:
		chk = line[x] + x + 1
		if chk == t:
			print('YES')
			c = False
		else:
			x = chk - 1


f = lambda : (int(x) for x in input().split())
(n, t) = f()
a = list(f())
c = 1
while c <= n - 1:
	if c == t:
		print('YES')
		break
	c = c + a[c - 1]
else:
	if c == t:
		print('YES')
	else:
		print('NO')


(n, t) = map(int, input().split())
a = [int(x) for x in input().split()]
p = 1
while p <= t:
	if p == t:
		print('YES')
		quit()
	p += a[p - 1]
print('NO')


from collections import defaultdict
graph = defaultdict(list)

def add_edge(i, ai):
	graph[i].append(ai)

def dfs(graph, s, n, t):
	visited = [False for node in range(n + 1)]
	stack = [s]
	while len(stack):
		s = stack[-1]
		if s == t:
			return True
		stack.pop()
		if not visited[s]:
			visited[s] = True
			for node in graph[s]:
				if not visited[node]:
					stack.append(node)
	return False
(n, t) = list(map(int, input().split()))
a = list(map(int, input().split()))
for i in range(0, n - 1):
	add_edge(i + 1, a[i] + i + 1)
if dfs(graph, 1, n, t):
	print('YES')
else:
	print('NO')


def cell():
	(cells, target) = map(int, input().split(' '))
	clist = list(map(int, input().split(' ')))
	clist = [0] + clist
	current = 1
	for i in range(cells - 1):
		nextcell = current + int(clist[current])
		if nextcell > target:
			print('NO')
			return
		elif nextcell == target:
			print('YES')
			return
		else:
			current = nextcell
cell()


(n, t) = input().split()
(n, t) = (int(n), int(t))
a = [int(i) for i in input().split()]
link = {}
for i in range(1, n):
	link[i] = a[i - 1]
cango = [1]
place = 1
count = 1
while place < n:
	count += 1
	place += link[place]
	cango.append(place)
if t in cango:
	print('YES')
else:
	print('NO')


(n, m) = input().split()
n = int(n)
m = int(m)
l = 1
count = 0
list2 = []
list1 = list(map(int, input().split()))
for i in range(len(list1)):
	if l <= len(list1):
		l = l + list1[l - 1]
		list2.append(l)
		if l == m:
			print('YES')
			break
for i in list2:
	if i != m:
		count += 1
if count == len(list2):
	print('NO')


(p, q) = map(int, input().split())
a = list(map(int, input().split()))
i = 0
while i <= p - 2:
	i = i + a[i]
	if i == q - 1:
		print('YES')
		exit(0)
print('NO')


(n, t) = map(int, input().split())
portals = list(map(int, input().split()))
res = 0
while res + 1 < t:
	res += portals[res]
else:
	if res + 1 == t:
		print('YES')
	else:
		print('NO')


def main():
	(n, t) = list(map(int, input().split()))
	way = list(map(int, input().split()))
	step = 0
	while t - 1 > step:
		step = way[step] + step
	if t - 1 == step:
		print('YES')
	else:
		print('NO')
	return
main()


(n, t) = input().split()
n = int(n)
t = int(t)
celula = []
celula = input().split()
for i in range(n - 1):
	celula[i] = int(celula[i])
flag = 1
add = 0
while flag:
	add += celula[add]
	if add + 1 == t:
		print('YES')
		flag = 0
	elif add + 1 > t:
		print('NO')
		flag = 0


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
lst = []
i = 1
while True:
	i = i + a[i - 1]
	if i == t:
		print('YES')
		break
	if i > t:
		print('NO')
		break


(n, t) = map(int, input().split())
l = list(map(int, input().split()))
currentPos = 1
possible = False
while True:
	if currentPos == t:
		possible = True
		break
	elif currentPos == n:
		break
	else:
		currentPos = l[currentPos - 1] + currentPos
if possible:
	print('YES')
else:
	print('NO')


(n, t) = [int(x) for x in input().split()]
n = n - 1
array = [int(x) for x in input().split()]
counter = 0
while True:
	if counter + 1 == t:
		print('YES')
		break
	elif counter > n - 1:
		print('NO')
		break
	counter = counter + array[counter]


(n, t) = input().split()
n = int(n)
t = int(t) - 1
arr = input().split()
arr.append('0')
ans = False
idx = 0
while not ans:
	if idx == t:
		ans = True
	if idx == n - 1:
		break
	idx += int(arr[idx])
if ans:
	print('YES')
else:
	print('NO')


(n, point_b) = list(map(int, input().split()))
data = list(map(int, input().split()))
position = 0
while True:
	position = position + data[position]
	if position + 1 == point_b:
		print('YES')
		break
	elif position + 1 > point_b:
		print('NO')
		break


(p, t) = map(int, input().split())
s = [0]
s += [int(n) for n in input().split()]
j = 1
while 1:
	j = s[j] + j
	if j == t:
		print('YES')
		break
	elif j == p:
		print('NO')
		break


(n, t) = list(map(int, input().split()))
y = list(map(int, input().split()))
lst = [1]
j = 1
while j <= len(y):
	j = j + y[j - 1]
	lst.append(j)
if t in set(lst):
	print('YES')
else:
	print('NO')


(n, t) = input().strip().split(' ')
n = int(n)
t = int(t)
t -= 1
n -= 1
an = input().strip().split(' ')
for i in range(n):
	an[i] = int(an[i])
x = 0
while x <= t:
	if x == t:
		break
	x = x + an[x]
if x == t:
	print('YES')
else:
	print('NO')


(n, t) = [int(x) for x in input().split()]
cells = [int(x) for x in input().split()]
jumps = 1
while jumps < t:
	jumps += cells[jumps - 1]
if jumps == t:
	print('YES')
else:
	print('NO')


arr = list(input().split(' '))
(n, t) = (int(arr[0]), int(arr[1]))
t -= 1
a = list(input().split(' '))
a = [int(x) for x in a]
res = False
j = 0
for i in range(n):
	j += a[j]
	if j == t:
		res = True
		break
	if j >= n - 1:
		break
if res == True:
	print('Yes')
else:
	print('No')


(n, t) = map(int, input().split())
arr = list(map(int, input().split()))
ok = False
idx = 1
while idx < n:
	idx = idx + arr[idx - 1]
	if idx == t:
		ok = True
print('YES' if ok else 'NO')


t = int(input().split(' ')[1])
ln2 = ('0 ' + input()).split(' ')
cur_pos = 1
while cur_pos < t:
	cur_pos += int(ln2[cur_pos])
print('YES') if cur_pos == t else print('NO')


a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
n = a[0]
t = a[1]
k = 1
s = 0
if t == 1:
	print('YES')
else:
	while k <= n - 1:
		k = k + b[k - 1]
		if k == t:
			s = 1
			print('YES')
			break
	if s == 0:
		print('NO')


def reachableVertices(g, v, f=[]):
	s = [v]
	if f == []:
		f = [0] * g.n
	r = []
	while s:
		u = s[-1]
		s.pop(-1)
		if f[u] == 1:
			continue
		r.append(u)
		f[u] = 1
		for e in g.outgoingEdges(u):
			s.append(e[1])
	return r

class AdjacencyList:

	def __init__(self, *a):
		if len(a) == 1:
			v = a[0].vertices()
			e = a[0].edges()
		else:
			v = a[0]
			e = a[1]
		self.m = len(e)
		self.v = [0] * v if type(v) == int else v
		self.n = len(self.v)
		self.e = [[] for i in range(self.n)]
		for i in e:
			self.e[i[0]] += [i]

	def vertices(self):
		return self.v

	def edges(self):
		return [j for i in range(self.n) for j in self.e[i]]

	def outgoingEdges(self, v):
		return self.e[v]

	def incomingEdges(self, v):
		return [j for i in range(self.n) for j in self.e[i] if j[1] == v]

	def addEdge(self, e):
		self.e[e[0]] += [e]

	def removeEdge(self, e):
		self.e[e[0]] = [i for i in self.e[e[0]] if i != e]

def readLine(*a):
	r = input().split()
	for i in range(len(r)):
		r[i] = a[min(i, len(a) - 1)](r[i])
	return r
Graph = AdjacencyList
(n, t) = readLine(int)
a = readLine(int)
g = Graph(n, [])
for i in range(n - 1):
	g.addEdge((i, i + a[i]))
print('YES' if reachableVertices(g, 0).count(t - 1) else 'NO')


def main():
	(n, end) = map(int, input().split())
	portals = list(map(int, input().split()))
	portals.insert(0, None)
	visited = {i: False for i in range(1, n + 1)}
	cnode = 1
	while True:
		if visited[cnode] is True:
			break
		visited[cnode] = True
		if cnode == end:
			print('YES')
			return
		try:
			cnode = cnode + portals[cnode]
		except IndexError:
			break
	print('NO')
main()


(n, t) = map(int, input().split())
l = list(map(int, input().split()))
s = 1
flag = 0
s = 1
i = 0
while True:
	s = s + l[i]
	i = i + l[i]
	if s == t:
		print('YES')
		break
	elif s > t:
		print('NO')
		break


(n, t) = map(int, input().split())
A = list(map(int, input().split()))
i = 1
while i < t:
	i += A[i - 1]
if i == t:
	print('YES')
else:
	print('NO')


(n, t) = list(map(int, input().split(' ')))
a = list(map(int, input().split(' ')))
marked = [False] * n
marked[0] = True
current = 0
while True:
	current = current + a[current]
	if current >= t:
		print('NO')
		exit()
	elif current == t - 1:
		print('YES')
		exit()
	elif marked[current]:
		print('NO')
		exit()
	else:
		marked[current] = True


from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
	return int(input())

def rl():
	return list(map(int, input().split()))
(n, t) = rl()
aa = [-1] + rl()
i = 1
while i < t:
	i = i + aa[i]
if i > t:
	print('NO')
else:
	print('YES')


(n, t) = map(int, input().split())
Str = input().split()
num = 1
for i in range(1, t + 1):
	num = num + int(Str[num - 1])
	if num == t:
		print('YES')
		break
	if num > t:
		print('NO')
		break


read = lambda : map(int, input().split())
(n, t) = read()
a = list(read())
cur = 1
while cur < t:
	cur += a[cur - 1]
print('YES' if cur == t else 'NO')


(n, k) = map(int, input().split())
list = [int(i) for i in input().split()]
i = 0
while i <= n - 1:
	if i == k - 1:
		print('YES')
		exit()
	if i == n - 1:
		break
	i += list[i]
print('NO')


(n1, t1) = input().split()
n = int(n1)
t = int(t1)
s = input().split()
l = 1
s = [int(i) for i in s]
while True:
	if l == 1:
		i = s[0]
	else:
		i = s[l - 1]
	l = l + i
	if l == t:
		print('YES')
		exit()
	if l > t:
		print('NO')
		exit()


(n, k) = list(map(int, input().split()))
t = list(map(int, input().split()))
u = 0
for h in range(n):
	if u < k - 1:
		if u == 0:
			u += t[u]
		else:
			u += t[u]
	elif u == k - 1:
		print('YES')
		break
	elif u > k - 1:
		print('NO')
		break


nt = input().split(' ')
n = int(nt[0])
t = int(nt[1])
nt2 = input().split(' ')
i = 1
while i < t:
	i += int(nt2[i - 1])
print('YES' if i == t else 'NO')


s = input().split(' ')
(n, t) = [int(s[i]) for i in range(0, 2)]
t -= 1
s = input().split(' ')
a = [int(s[i]) for i in range(0, n - 1)]
i = 0
while i < t:
	i += a[i]
if i == t:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
nis = list(map(int, input().split()))
visitar = set()
pos = 0
visitar.add(pos)
while pos < len(nis):
	pos += nis[pos]
	visitar.add(pos)
print('YES') if t - 1 in visitar else print('NO')


def main():
	(n, t) = map(int, input().split())
	a = tuple(map(int, input().split()))
	f = [False] * (n + 1)
	f[1] = True
	for i in range(1, n):
		if f[i]:
			f[i + a[i - 1]] = True
	print('YES' if f[t] else 'NO')
main()


destination = int(input().split()[1]) - 1
a = list(map(int, input().split()))
current = 0
while current < destination:
	current += a[current]
if current == destination:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
portal = {}
for i in range(1, n):
	portal[i] = i + a[i - 1]
s = 1
for _ in range(n + 1):
	s = portal.get(s)
	if s == t:
		print('YES')
		break
	if s == None:
		print('NO')
		break
else:
	print('NO')


l = list(map(int, input().split()))
m = l[0]
t = l[1]
n = list(map(int, input().split()))
l = []
flag = 0
i = 0
while i < m - 1:
	i = i + n[i]
	l.append(i + 1)
if t in l:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
ai = list(map(int, input().split()))
ni = ''
error = 0
yes = 0
last_chil = 1
while error == 0 and yes == 0:
	if last_chil > n - 1:
		error = 1
	else:
		z = last_chil + ai[last_chil - 1]
		if ni.find(str(z)) == -1:
			last_chil = z
			if last_chil == t:
				yes = 1
		else:
			error = 1
if yes == 1:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
t = t - 1
x = list(map(int, input().split()))
i = 0
flag = False
while i < n:
	if i == t:
		flag = True
		break
	else:
		flag = False
	try:
		i = i + x[i]
	except:
		break
if flag == True:
	print('YES')
else:
	print('NO')


(n, t) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
m = 1
k = 0
while m < n:
	m += a[m - 1]
	if m == t:
		k = 1
		print('YES')
		break
if k == 0:
	print('NO')


(numbers, find) = list(map(int, input().split(' ')))
board = list(map(int, input().split(' ')))
board += [10]
i = 1
while i <= numbers and board[i - 1] + i <= find:
	i = board[i - 1] + i
if find == i:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
k = 0
m = list(map(int, input().split()))
try:
	for i in range(n):
		if m[k] + k == t - 1:
			print('YES')
			break
		else:
			k += m[k]
except:
	print('NO')


from __future__ import division, print_function
import itertools, os, sys, threading
from collections import deque, Counter, OrderedDict, defaultdict

def ii():
	return int(input())

def si():
	return str(input())

def mi():
	return map(int, input().strip().split(' '))

def li():
	return list(mi())

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, num):
	return [[num for x in range(n)] for y in range(n)]

def ntl(n):
	return [int(i) for i in str(n)]

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
visited = [False] * 1000000

class Graph:

	def __init__(self):
		self.graph = defaultdict(list)

	def addEdge(self, u, v):
		self.graph[u].append(v)

	def DFSUtil(self, v, visited):
		visited[v] = True
		for i in self.graph[v]:
			if visited[i] == False:
				self.DFSUtil(i, visited)

	def dfs(self, v):
		self.DFSUtil(v, visited)

def main():
	g = Graph()
	(n, t) = mi()
	l = li()
	for i in range(1, n):
		g.addEdge(i, l[i - 1] + i)
	g.dfs(1)
	if visited[t] == True:
		print('YES')
	else:
		print('NO')
sys.setrecursionlimit(100000000)
threading.stack_size(10240000)
thread = threading.Thread(target=main)
thread.start()


(n, t) = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
m = [0] * n
for i in range(n - 1):
	m[i] = i + 1 + l[i]
s = 1
k = []
while True:
	if s != m[s - 1]:
		s = m[s - 1]
		k.append(s)
	else:
		break
print('YES' if t in k else 'NO')


(n, t) = [int(s) for s in input().split()]
arr = [int(s) for s in input().split()]
arr.insert(0, 0)
idx = 1
while idx <= n - 1:
	value = arr[idx]
	idx = arr[idx] + idx
	if idx == t:
		flag = True
		break
	else:
		flag = False
if flag:
	print('YES')
else:
	print('NO')


(a, b) = map(int, input().split())
s = input().split()
x = [int(i) for i in s]
n = 1
while n < b:
	n += x[n - 1]
if n == b:
	print('Yes')
if n > b:
	print('No')


def dfs_iterative(graph, node):
	(stack, path) = ([node], [])
	while stack:
		vertex = stack.pop()
		if vertex in path:
			continue
		path.append(vertex)
		for neighbor in graph[vertex]:
			stack.append(neighbor)
	return path
(n, t) = map(int, input().split())
arr = list(map(int, input().split()))
graph = {i: set() for i in range(1, n + 1)}
for i in range(n - 1):
	graph[i + 1] = graph[i + 1].union(set([i + 1 + arr[i]]))
path = dfs_iterative(graph, 1)
if t in path:
	print('YES')
else:
	print('NO')


(n, t) = [int(j) for j in input().split()]
l = [0] + [int(i) for i in input().split()] + [0]
cur = 1
alert = 0
while cur < n:
	cur = cur + l[cur]
	if cur == t:
		alert = 1
		print('YES')
		break
if alert == 0:
	print('NO')


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
c = 1
while c < n:
	c = c + a[c - 1]
	if c == k:
		print('YES')
		break
	elif c > k:
		print('NO')
		break


(n, t) = [int(x) for x in input().split()]
s = [int(x) for x in input().split()]
p = []
k = 1
while k < n:
	k += s[k - 1]
	p.append(k)
if t in p:
	print('YES')
else:
	print('NO')


(n, m) = list(map(int, input().split()))
arr = list(map(int, input().split()))
cur_cell = 1
while cur_cell < m:
	cur_cell += arr[cur_cell - 1]
print('YES' if cur_cell == m else 'NO')


(n, t) = [int(i) for i in input().split()]
t -= 1
data = [int(i) for i in input().split()]
pos = 0
while pos != n - 1:
	pos += data[pos]
	if pos == t:
		print('YES')
		quit()
print('NO')


(n, t) = map(int, input().split())
L = list(map(int, input().split())) + [0]
flag = False
x = 0
while x < t:
	if x + 1 == t:
		flag = True
		break
	x += L[x]
if flag:
	print('YES')
else:
	print('NO')


l = input().split(' ')
(n, t) = (int(l[0]), int(l[1]))
a = [int(k) for k in input().split(' ')]
x = 1
fl = True
while fl and x <= t:
	if x == t:
		fl = False
	else:
		x += a[x - 1]
if fl:
	print('NO')
else:
	print('YES')


a = list(map(int, input().strip(' ').split(' ')))
s = list(map(int, input().strip(' ').split(' ')))
s.insert(0, 0)
k = 1
su = 0
while True:
	jump = k + s[k]
	if jump == a[1]:
		print('YES')
		break
	if jump > a[1]:
		print('NO')
		break
	k = jump


(n, destination) = map(int, input().split())
panels = [int(i) for i in input().split()]
loc = 1
while loc < destination:
	loc += panels[loc - 1]
if loc == destination:
	print('YES')
else:
	print('NO')


def foo(t, n, a, visited):
	start = 0
	while start < n - 1:
		start += a[start]
		if start == t - 1:
			return True
	return False
(n, t) = [int(s) for s in input().split()]
a = [int(s) for s in input().split()]
visited = [False] * n
if foo(t, n, a, visited):
	print('YES')
else:
	print('NO')


(n, t) = [int(i) for i in input().split()]
a = 1
s = [0] + [int(i) for i in input().split()]
p = 0
while a < t and p < n:
	p += 1
	a += s[a]
if a == t:
	print('YES')
else:
	print('NO')


(n, m) = [int(x) for x in input().split()]
L = [int(x) for x in input().split()]
t = 1
while t < m:
	t = t + L[t - 1]
if t == m:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
t -= 1
point = 0
a = list(map(int, input().split()))
now = 0
while point < t:
	if now == point:
		point += a[now]
	now += 1
if point == t:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
arr = list(map(int, input().split()))
cur = 0
was = False
while cur < n:
	try:
		cur = cur + arr[cur]
		if cur == t - 1:
			was = True
	except:
		break
if was:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
port = list(map(int, input().split()))
f = 1
while f < t:
	f = f + port[f - 1]
if f == t:
	print('YES')
else:
	print('NO')


class Solution(object):

	def __init__(self):
		(self.n, self.t) = map(int, input().split())
		self.a = [0] + list(map(int, input().split()))
		d = 1 + self.a[1]
		while d < self.t:
			d = d + self.a[d]
		print('YES') if d == self.t else print('NO')
	pass

def main():
	Solution()
	pass
main()


(n, destination) = map(int, input().strip().split())
portals = list(map(int, input().strip().split()))
current = 1
while current < destination:
	current = current + portals[current - 1]
if current == destination:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
talika = []
index = 0
for i in range(n - 1):
	index = a[index] + index
	talika.append(index + 1)
	if index > n - 2:
		break
print('YES' if t in talika else 'NO')


import sys
nt = input().split()
n = int(nt.pop(0))
t = int(nt.pop(0))
a = [int(i) for i in input().split()]
p = 0
while p < t - 1:
	p += a[p]
if p == t - 1:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
ans = 'NO'
i = 0
while True:
	if i == t - 1:
		ans = 'YES'
		break
	elif i > t - 1:
		break
	else:
		i = i + a[i]
print(ans)


import sys
(n, t) = list(map(int, input().split()))
t -= 1
a = list(map(int, input().split()))
a.append(1)
v = 0
while v <= n - 1:
	if v == t:
		print('YES')
		sys.exit()
	v += a[v]
print('NO')


a = list(map(int, input().split()))
n = a[0]
t = a[1]
b = list(map(int, input().split()))
b.insert(0, '')
curr = 1
while curr < t:
	ai = b[curr]
	curr = curr + ai
if curr == t:
	print('YES')
else:
	print('NO')


(n, t) = input().split()
n = int(n)
t = int(t)
a = [int(i) for i in input().split()]
done = 0

def find(start, final):
	global done
	if start == final:
		done += 1
		return
	if done == 0 and start < final:
		find(a[start] + start, final)
start = 1
final = t
while start < final:
	start += a[start - 1]
if start == final:
	print('YES')
else:
	print('NO')


def cell(n, t, a):
	h = 1
	while h < t:
		h += a[h - 1]
	if h == t:
		return 'YES'
	else:
		return 'NO'
(n, t) = list(map(int, input().split()))
a = list(map(int, input().split()))
print(cell(n, t, a))


(places, dest) = map(int, input().split(' '))
portals = list(map(int, input().split(' ')))
current_position = 1
visited = set()
visited.add(current_position)
while current_position < places:
	portal = portals[current_position - 1]
	current_position = current_position + portal
	visited.add(current_position)
print('YES') if dest in visited else print('NO')


(n, t) = list(map(int, input().split()))
a = list(map(int, input().split()))
i = 1
while True:
	if i + a[i - 1] == t:
		print('YES')
		break
	elif i + a[i - 1] > t or i + a[i - 1] > len(a):
		print('NO')
		break
	else:
		i = i + a[i - 1]


(n, t) = map(int, input().split())
lis = list(map(int, input().split()))
k = 0
t -= 1
while k < t:
	k = k + lis[k]
if k == t:
	print('YES')
else:
	print('NO')


import sys
import threading
sys.setrecursionlimit(30000)

def main():
	(n, t) = list(map(lambda a: a - 1, list(map(int, input().split()))))
	a = list(map(int, input().split()))

	def explore(i, t):
		if i > t:
			return False
		elif i == t:
			return True
		else:
			return explore(a[i] + i, t)
	if explore(0, t) == True:
		print('YES')
	else:
		print('NO')
threading.stack_size(100000000)
thread = threading.Thread(target=main)
thread.start()


def check_cell(n, t, portals):
	pos = 1
	i = 0
	while pos < t:
		pos += portals[i]
		i += portals[i]
		if pos > t:
			return False
	return True

def main():
	(n, t) = [int(i) for i in input().split()]
	portals = [int(i) for i in input().split()]
	if check_cell(n, t, portals):
		print('YES')
	else:
		print('NO')
main()


(n, t) = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
t -= 1
val = 0
i = 0
while i < n - 1:
	val = i + l[i]
	if val == t:
		break
	i = val
if val == t:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
i = 0
v = [0] * n
while i < n - 1:
	i += a[i]
	v[i] = 1
if v[k - 1] == 0:
	print('No')
else:
	print('YES')


(n, t) = list(map(int, input().split()))
A = list(map(int, input().split()))
A.append(1)
i = 1
while i <= n:
	if i == t:
		print('YES')
		exit()
	i += A[i - 1]
print('NO')


S = input().split()
n = int(S[0])
t = int(S[1])
S1 = []
l = list(map(int, input().split()))
i = 0
while i < t - 1:
	i = i + l[i]
if i + 1 == t:
	print('YES')
else:
	print('NO')


import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
(N, T) = map(int, input().split())
A = [0] + [int(x) for x in input().split()]
t = 1
while t <= N:
	if t == T:
		print('YES')
		exit(0)
	elif t > T:
		print('NO')
		exit(0)
	t += A[t]
print('NO')


(n, t) = map(int, input().strip().split(' '))
way = list(map(int, input().strip().split(' ')))
t = t - 1
p = 0
while True:
	if p == t:
		print('YES')
		break
	if p > t:
		print('NO')
		break
	p += way[p]


import sys
import threading

def main():

	def dfs(s, vis):
		vis[s] = 1
		for x in g[s]:
			if not vis[x]:
				dfs(x, vis)
	(n, t) = map(int, input().split())
	arr = [int(x) for x in input().split()]
	vis = [0] * n
	g = [[] for i in range(n)]
	for (i, x) in enumerate(arr):
		g[i].append(i + x)
	dfs(0, vis)
	print('YES' if vis[t - 1] else 'NO')
sys.setrecursionlimit(10 ** 6)
threading.stack_size(10 ** 8)
main_thread = threading.Thread(target=main)
main_thread.start()
main_thread.join()


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
done = set()
p = 1
while True:
	if p == t:
		print('YES')
		break
	if p in done or p > t:
		print('NO')
		break
	done.add(p)
	p += a[p - 1]


(n, t) = map(int, input().split())
d = list(map(int, input().split()))
pos = 1
while pos < n:
	pos += d[pos - 1]
	if pos == t:
		print('YES')
		exit(0)
print('NO')


[n, t] = [int(x) for x in input().split()]
portals = [int(x) for x in input().split()]
tmp = 1
while tmp < t:
	tmp = tmp + portals[tmp - 1]
if tmp == t:
	print('YES')
else:
	print('NO')


(n, c) = map(int, input().split())
l = [int(i) for i in input().split()]
i = 0
while True:
	if i + 1 == c:
		print('YES')
		break
	elif i + 1 > c:
		print('NO')
		break
	else:
		i += l[i]


[a, b] = [int(a) for a in input().split(' ')]
groups = [int(a) for a in input().split(' ')]
count = 0
sum = 0
while True:
	i = groups[count]
	count = count + i
	if count == b - 1:
		print('YES')
		exit()
	elif count > b - 1:
		print('NO')
		exit()


inp = input().split(' ')
end = int(inp[1]) - 1
nums = input().split(' ')
nums = list(map(int, nums))
i = 0
while i < end:
	i = i + nums[i]
if i == end:
	print('YES')
else:
	print('NO')


from collections import defaultdict

def dfs(stack, visited, g, er):
	while stack:
		p = stack.pop()
		if visited[p] == 0:
			visited[p] += 1
			er.append(p + 1)
		for i in g[p]:
			if visited[i] == 0:
				stack.append(i)
g = defaultdict(list)
(e, fin) = map(int, input().split())
l = list(map(int, input().split()))
for i in range(e - 1):
	(a, b) = (i, l[i] + i)
	a = a
	b = b
	g[a].append(b)
visited = [0] * e
stack = [0]
er = []
dfs(stack, visited, g, er)
if visited[fin - 1] == 1:
	print('YES')
else:
	print('NO')


def main():
	(n, t) = [int(s) for s in input().split()]
	arr = [int(s) for s in input().split()]
	i = 0
	while i < n - 1:
		i = i + arr[i]
		if i == t - 1:
			print('YES')
			break
	else:
		print('NO')
main()


(n, t) = map(int, input().split())
p = list(map(int, input().split()))
o = 1
while o <= n - 1:
	o = o + p[o - 1]
	flg = 1
	if o == t:
		flg = 1
		break
	else:
		flg = 0
print(('NO', 'YES')[flg])


k = list(map(int, input().split()))
A = list(map(int, input().split()))
cell = 1
result = 'NO'
while cell < k[0]:
	cell = cell + A[cell - 1]
	if cell == k[1]:
		result = 'YES'
		break
print(result)


(x, y) = [int(a) for a in input().split()]
z = [int(a) for a in input().split()]
i = 0
while i < y - 1:
	i += z[i]
if i == y - 1:
	print('YES')
else:
	print('NO')


(n, t) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
mark = False
i = 0
while i != t - 1 and i < n - 1:
	i += a[i]
	if i == t - 1:
		print('YES')
		mark = True
if not mark:
	print('NO')


(n, t) = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
a = n * [0]
for i in range(1, n):
	a[i] = i + c[i - 1]
i = 1
while i != t:
	i = a[i]
	if i == 1 or i > t:
		break
if i == t:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
t -= 1
l = [int(j) for j in input().split()]
sp = [0] * n
q = [0]
sp[0] = 1
while q:
	x = q.pop()
	if x >= n - 1:
		break
	d = l[x] + x
	if sp[d] == 0:
		sp[d] = 1
		q.append(d)
if sp[t]:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
L = list(map(int, input().split()))
world = {}
for i in range(1, n):
	world[i] = L[i - 1] + i
pos = 1
while pos != t and pos < t:
	pos = world[pos]
if pos == t:
	print('YES')
else:
	print('NO')


l = []
(n, t) = map(int, input().split())
l1 = list(map(int, input().split()))
i = 1
while i < t:
	i = i + l1[i - 1]
	l.append(i)
if t in l:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
fila = list(map(int, input().split()))
if n == t:
	print('YES')
else:
	lugar = 0
	while lugar < t - 1:
		lugar += fila[lugar]
	if lugar == t - 1:
		print('YES')
	else:
		print('NO')


nt = [int(x) for x in input().split()]
data = [int(x) for x in input().split()]
stat = 1
while stat < nt[1]:
	stat += data[stat - 1]
print('YES' if stat == nt[1] else 'NO')


(n, t) = map(lambda x: int(x) - 1, input().split())
x = list(map(int, input().split()))
i = 0
ans = 'NO'
while i < t:
	i += x[i]
	if i == t:
		ans = 'YES'
	if i >= t:
		break
print(ans)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
visitable = {0}
for (i, aa) in enumerate(a[:t - 1]):
	if i in visitable:
		visitable.add(i + aa)
if t - 1 in visitable:
	print('YES')
else:
	print('NO')


from sys import stdin, stdout, maxsize
tup = lambda : map(int, stdin.readline().split())
I = lambda : int(stdin.readline())
lint = lambda : [int(x) for x in stdin.readline().split()]
stpr = lambda x: stdout.write(f'{x}' + '\n')
(n, m) = tup()
ls = lint()
i = 1
c = 0
while i < m:
	i += ls[i - 1]
print('YES') if i == m else print('NO')


(n, t) = map(int, input().split())
a = input().split()
index = 1
dest = 0
while dest <= t:
	dest = index + int(a[index - 1])
	if dest == t:
		print('Yes')
		exit()
	index = dest
print('No')


def func():
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	t -= 1
	pos = 0
	while pos < len(a):
		pos += a[pos]
		if pos == t:
			print('YES')
			return
	print('NO')
func()


(n, target) = [int(t) for t in input().split()]
index = 0
arr = [int(v) for v in input().split()]
found = 0
while index + 1 <= target and found != 1:
	if arr[index] + index + 1 == target:
		print('YES')
		found = 1
	else:
		index = index + arr[index]
if found == 0:
	print('NO')


(n, t) = input().split()
n = int(n)
t = int(t)
listt = input().split()
k = 1
g = 0
for i in range(n - 1):
	if k >= t:
		break
	k = k + int(listt[k - 1])
if k == t:
	print('YES')
else:
	print('NO')


input_s = input().split(' ')
input_l = input().split(' ')
list_l = []
for l in input_l:
	list_l.append(int(l))
i = 0
j = int(input_s[1]) - 1
is_ok = False
while i < j:
	i = list_l[i] + i
	if i == j:
		is_ok = True
if is_ok:
	print('YES')
else:
	print('NO')


(no_of_cells, index_to_be_reached) = map(int, input().split())
cells_list = list(map(int, input().split()))[:no_of_cells]
current_index = 1
for index in range(0, no_of_cells):
	if current_index < index_to_be_reached:
		current_index = cells_list[current_index - 1] + current_index
	elif current_index == index_to_be_reached:
		print('YES')
		break
	else:
		print('NO')
		break


(n, t) = map(int, input().split())
A = list(map(int, input().split()))
out = 'NO'
i = 0
while i < n - 1:
	if i + 1 == t:
		out = 'YES'
		break
	else:
		i += A[i]
if i + 1 == t:
	out = 'YES'
print(out)


(n, t) = map(int, input().split())
a = [int(x) for x in input().split()]
c = 1
while c < t:
	c += a[c - 1]
	if c == t:
		print('YES')
		break
else:
	print('NO')


(n, c) = [int(x) for x in input().split()]
portal = [int(x) for x in input().split()]
loc = 1
count = 0
while loc < n:
	loc = loc + portal[loc - 1]
	if loc == c:
		print('YES')
		count = 1
		break
if count == 0:
	print('NO')


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
c = [0] * (n + 1)
c[0] = 1
for i in range(n - 1):
	if i + a[i] < n and c[i] == 1:
		c[i + a[i]] = 1
if c[m - 1] == 1:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
k -= 1
i = 0
f = 0
while i <= k:
	if i == k:
		f = 1
		break
	i = i + l[i]
if f == 1:
	print('YES')
else:
	print('NO')


from collections import defaultdict

def dfs(graph, target):
	(visited, stack) = (set(), [1])
	while stack:
		vertex = stack.pop()
		if vertex not in visited:
			visited.add(vertex)
			if vertex == target:
				return True
			stack.extend(set(graph[vertex]) - visited)
	return False
(n, t) = map(int, input().split())
a = list(map(int, input().split()))
s = defaultdict(set)
for i in range(1, n):
	s[i].add(i + a[i - 1])
print('YNEOS'[not dfs(s, t)::2])


(n, t) = [int(i) for i in input().split()]
g = [0] + [int(i) for i in input().split()]
l = False
start = 1
while True:
	if start == t:
		print('YES')
		l = True
		break
	if start >= n:
		break
	start += g[start]
if not l:
	print('NO')


in1 = input().split()
n = int(in1[0]) - 1
t = int(in1[1]) - 1
arr = input().split()
for i in range(n):
	arr[i] = int(arr[i])
x = 0
while x < t:
	x += arr[x]
if x == t:
	print('YES')
else:
	print('NO')


def newYear(n, t, list):
	i = 1
	while i < t:
		i += list[i - 1]
	if i == t:
		print('YES')
		return
	print('NO')
	return
params = input().split()
n = int(params[0])
t = int(params[1])
params = input().split()
for i in range(len(params)):
	params[i] = int(params[i])
newYear(n, t, params)


(n, t) = map(int, input().split())
lst = list(map(int, input().split()))
i = 0
flag = False
zeta = 1
while i < n:
	if zeta == t:
		flag = True
		break
	else:
		try:
			zeta += lst[i]
		except IndexError:
			break
		i = zeta - 1
if flag:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
i = 1
while i < k:
	i += l[i - 1]
if i == k:
	print('YES')
else:
	print('NO')


A = [int(X) for X in input().split()]
S = [int(Y) for Y in input().split()]
M = 1
while M < A[1]:
	M += S[M - 1]
if M == A[1]:
	print('YES')
else:
	print('NO')


(n, t) = input().split()
ai = input().split()
d = {}
for i in range(0, int(n) - 1):
	d[i + 1] = int(ai[i])
check = 0
i = 1
while i <= int(t):
	i = i + d[i]
	if i == int(t):
		check = 1
		print('YES')
		break
if check == 0:
	print('NO')


y = int(input().split()[1])
z = [0] + list(map(int, input().split()))
i = 1
while i < y:
	i += z[i]
print('YES' if i == y else 'NO')


x = [int(i) for i in list(input().split())]
y = [int(i) for i in list(input().split())]
q = 1
while q < x[1]:
	q += y[q - 1]
if q == x[1]:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
portal = [int(i) for i in input().split()]
reachable = []
s = 1
while s <= n - 1:
	s += portal[s - 1]
	reachable.append(s)
print(['NO', 'YES'][t in reachable])


class Graph:

	def __init__(self, V):
		self.v = V
		self.graph = {i: [] for i in range(V)}

	def addEdge(self, u, v):
		if u in self.graph:
			self.graph[u].append(v)
		else:
			self.graph[u] = [v]

	def destination(self, u):
		stack = [0]
		visited = [False] * self.v
		visited[0] = 1
		while len(stack) != 0:
			a = stack.pop(-1)
			for v in self.graph[a]:
				if visited[v] == False:
					visited[v] = True
					stack.append(v)
		if visited[u] == True:
			return 'YES'
		else:
			return 'NO'
(n, t) = input().split()
n = int(n)
t = int(t)
lst1 = list(map(int, input().split()))
g = Graph(n)
for i in range(len(lst1)):
	g.addEdge(i, i + lst1[i])
print(g.destination(t - 1))


(num_de_celulas, indice_destino) = list(map(int, input().split()))
celulas = list(map(int, input().split()))
aux = 0
while aux < indice_destino - 1:
	aux += celulas[aux]
if aux == indice_destino - 1:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
li = [int(x) for x in input().split()]
k = 1
ll = []
while k < n:
	k = k + li[k - 1]
	ll.append(k)
if t in ll:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
a = [int(i) for i in input().split()]
a.insert(0, 0)
i = 1
f = 0
l = []
while i <= n:
	if i == t:
		f = 1
		break
	elif i > t:
		break
	else:
		i = a[i] + i
		l.append(i)
if f == 0:
	print('NO')
else:
	print('YES')


(length, cell) = map(int, input().split())
cells = list(map(int, input().split()))
position = 0
while position < length - 1:
	if position + 1 == cell:
		break
	else:
		position += cells[position]
if position + 1 == cell:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
ls = [0]
ls += list(map(int, input().split()))
sig = 1
flag = False
while sig <= t:
	if sig == t:
		flag = True
		break
	else:
		sig += ls[sig]
print('NO') if flag == False else print('YES')


(N, D) = map(int, input().split())
A = list(map(int, input().split()))
cur = 0
ind = 0
while cur < D - 1:
	cur += A[cur]
if cur == D - 1:
	print('YES')
else:
	print('NO')


(n, t) = input().split(' ')
list1 = input().split(' ')
list2 = []
n = int(n)
i = 1
while i < n:
	list2.append(str(i))
	i += int(list1[i - 1])
list2.append(str(n))
if t in list2:
	print('YES')
else:
	print('NO')


(num_cells, target_cell) = [int(x) for x in input().split()]
portals = [int(x) for x in input().split()]
current = 0
possible = False
for i in range(num_cells):
	if current == target_cell - 1:
		possible = True
		break
	elif current >= num_cells - 1:
		break
	else:
		current += portals[current]
if possible:
	print('YES')
else:
	print('NO')


(n, t) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
i = 1
while True:
	if i == t:
		print('YES')
		break
	elif i >= n:
		print('NO')
		break
	else:
		i += a[i - 1]


(n, t) = map(int, input().split())

def f():
	if t == 1:
		return 'YES'
	list1 = list(map(int, input().split()))
	i = 1
	while i < n:
		i += list1[i - 1]
		if i == t:
			return 'YES'
	return 'NO'
print(f())


nt = [int(i) for i in input().split()]
n = nt[0]
t = nt[1]
cells = [int(i) for i in input().split()]
cells.insert(0, 0)
position = 1
while True:
	if position == t:
		print('YES')
		break
	elif position >= n:
		print('NO')
		break
	else:
		position += cells[position]


(n, t) = list(map(int, input().split()))
A = list(map(int, input().split()))
cur = 1
for i in range(0, n - 1):
	if i + 1 == cur:
		cur += A[i]
	if cur == t:
		print('YES')
		exit(0)
print('NO')


TN = 1

def solution():
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	cur = 1
	while True:
		if cur == t:
			print('YES')
			break
		if cur > t:
			print('NO')
			break
		else:
			cur = cur + a[cur - 1]
while TN != 0:
	solution()
	TN -= 1


(n, t) = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
n = n - 1
t = t - 1
i = 0
while i < n:
	if i == t or i + arr[i] == t:
		print('YES')
		break
	elif i == n - 1 or i + arr[i] >= n:
		print('NO')
	i = i + arr[i]


import math as mt
import sys, string
input = sys.stdin.readline
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
from collections import defaultdict

def dfs(n, dx):
	vis[n] = 1
	dis[n] = dx
	for i in adj[n]:
		if vis[i] == 0:
			dfs(i, dx + 1)
(n, k) = M()
l = L()
i = 0
while i < k - 1:
	i += l[i]
if i == k - 1:
	print('YES')
else:
	print('NO')


def dfs(s, t, graph):
	visited = [False] * len(graph)
	stack = [s]
	while stack:
		v = stack.pop()
		if not visited[v]:
			if v == t:
				return True
			visited[v] = True
		for adj in graph[v]:
			if not visited[adj]:
				stack.append(adj)
	return False
(n, t) = map(int, input().split())
a = map(int, input().split())
graph = [[] for _ in range(n)]
for (i, a_i) in enumerate(a):
	graph[i].append(i + a_i)
res = dfs(0, t - 1, graph)
print('YES' if res else 'NO')


(n, k) = map(int, input().split())
d = {}
for i in range(1, n + 1):
	d[i] = set()
lst = list(map(int, input().split()))
for i in range(n - 1):
	a = i + 1
	a += lst[i]
	d[i + 1].add(a)
visited = [0] * (n + 1)

def bfs(s):
	global d, n, k, visited
	q = []
	visited[s] = 1
	q.append(s)
	while q:
		p = q.pop(0)
		for i in d[p]:
			if visited[i] == 0:
				visited[i] = 1
				q.append(i)
bfs(1)
if visited[k] == 1:
	print('YES')
else:
	print('NO')


(n, t) = [int(x) for x in input().split()]
List = [int(x) for x in input().split()]
current = 1
count = 0
while current < t:
	current += List[count]
	count = current - 1
if current == t:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
A = [*map(int, input().split())]
S = set([1])
Q = [1]
A.append(0)
ans = False
while Q:
	n = Q.pop()
	nxt = n + A[n - 1]
	if nxt == t:
		ans = True
		break
	if nxt not in S:
		S.add(nxt)
		Q.append(nxt)
print('YES' if ans else 'NO')


(n, t) = [int(a) for a in input().split()]
a = [int(i) for i in input().split()]
adjacency_list = [[] for i in range(n)]
for i in range(len(a)):
	adjacency_list[i].append(a[i] + i)

def bfs(start, end):
	queue = [start]
	while queue:
		for node in adjacency_list[start]:
			if node == end:
				return True
			queue.append(node)
		start = queue.pop()
	return False
if bfs(0, t - 1):
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split(' '))
li = list(map(int, input().split(' ')))
i = 0
ans = 'NO'
lii = [1]
while i < n - 1:
	a = i + 1 + li[i]
	lii.append(a)
	i += 1
i = 1
flag = True
while flag:
	if lii[i] == t:
		ans = 'YES'
		break
	i = lii[i]
	if i >= n:
		flag = False
		break
print(ans)


(n, t) = map(int, input().split())
ds = list(map(int, input().split()))
curr = 0
while curr < t - 1:
	curr += ds[curr]
print(('NO', 'YES')[curr == t - 1])


fl = list(map(int, input().split()))
sl = list(map(int, input().split()))
myLocation = 1
list = [1]
while myLocation <= len(sl):
	myLocation = myLocation + sl[myLocation - 1]
	list.append(myLocation)
if fl[1] in list:
	print('YES')
else:
	print('NO')


def printSol(dest, t):
	su = 1
	for i in dest:
		now = su + dest[su - 1]
		if now == t:
			return 'YES'
		elif now > t:
			break
		su = now
	return 'NO'
(n, t) = map(int, input().split())
dest = list(map(int, input().split()))
print(printSol(dest, t))


import sys
an = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]
t = 1
while t < an[1]:
	t = t + p[t - 1]
	if t == an[1]:
		print('YES')
		sys.exit()
print('NO')


import collections
graph = collections.defaultdict(list)
(n, elem) = map(int, input().split())
l = list(map(int, input().split()))
for t in range(n - 1):
	graph[t + 1].append(l[t] + t + 1)
t = 1
c = 0
while True:
	try:
		if graph[t][0] == elem:
			c = 1
			break
		else:
			t = graph[t][0]
	except:
		break
if c == 1:
	print('YES')
else:
	print('NO')


(n, t) = [int(i) for i in input().split()]
integers = [int(a) for a in input().split()]
v = 0
while v < t - 1:
	v = v + integers[v]
if v == t - 1:
	print('YES')
else:
	print('NO')


line = input().split()
n = int(line[0])
t = int(line[1])
visited = {0}
line = [int(i) for i in input().split()]
current = 1
while current != t:
	if current in visited or current > len(line):
		print('NO')
		break
	else:
		visited.add(current)
		current += line[current - 1]
if current == t:
	print('YES')


(n, t) = map(int, input().split())
data = list(map(int, input().split()))
i = 0
while i < len(data):
	if data[i] + i + 1 == t:
		print('YES')
		break
	elif data[i] + i + 1 < t:
		i = data[i] + i
	else:
		print('NO')
		break


import math
from collections import defaultdict, Counter, deque
INF = float('inf')

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def isPrime(n):
	if n <= 1:
		return False
	i = 2
	while i ** 2 <= n:
		if n % i == 0:
			return False
		i += 1
	return True

def primeFactor(n):
	if n % 2 == 0:
		return 2
	i = 3
	while i ** 2 <= n:
		if n % i == 0:
			return i
		i += 1
	return n

def vars():
	return map(int, input().split())

def array():
	return list(map(int, input().split()))

def main():
	(n, r) = vars()
	arr = array()
	i = 1
	while i < r:
		i = i + arr[i - 1]
	if i == r:
		print('YES')
	else:
		print('NO')
t = 1
for _ in range(t):
	main()


(n, t) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
cur = 1
while cur != t and cur != n:
	cur += a[cur - 1]
print('YES' if cur == t else 'NO')


(n, l, c) = (int(input().split()[1]) - 1, list(map(int, input().split())), 0)
while c < n:
	c += l[c]
print('YNEOS'[c > n::2])


(n, t) = map(int, input().split())
res = []
i = 0
a = [int(x) for x in input().split()] + [1]
while i in range(n):
	res.append(i + 1)
	i += a[i]
print('YNEOS'[t not in res::2])


(n, t) = map(int, input().split())
l = list(map(int, input().split()))
y = False
i = 0
while i < n - 1:
	if i + l[i] == t - 1:
		y = True
		break
	i += l[i]
if y:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
l = list(map(int, input().split()))
i = 1
flag = 'NO'
while 1:
	if i == t:
		flag = 'YES'
		break
	if i > t or i >= n:
		break
	i += l[i - 1]
print(flag)


(buniek, ciel) = map(int, input().split())
bunky = list(map(int, input().split()))
aktualna = 1
while aktualna < ciel:
	aktualna += bunky[aktualna - 1]
if aktualna == ciel:
	print('YES')
else:
	print('NO')


line = input().split()
n = int(line[0])
t = int(line[1])
nums = list(map(int, input().split()))
s = 1
while True:
	if s > t:
		print('NO')
		break
	if s == t:
		print('YES')
		break
	s += nums[s - 1]


entrada = input().split(' ')
n = int(entrada[0])
t = int(entrada[1])
cells = [0]
cells = cells + input().split(' ')
cela_atual = 0
cela_anterior = 1
i = 0
while i <= n:
	cela_atual = cela_anterior + int(cells[cela_anterior])
	if cela_atual == t:
		print('YES')
		break
	elif cela_atual > t:
		print('NO')
		break
	else:
		cela_anterior = cela_atual
	i += 1


(n, t) = tuple(map(int, input().split()))
portals = list(map(int, input().split()))
cell = 1
if t == 1:
	print('YES')
	quit()
while True:
	cell += portals[cell - 1]
	if cell == t:
		print('YES')
		quit()
	elif cell > t:
		print('NO')
		quit()


(n, t) = list(map(int, input().split()))
a = list(map(int, input().split()))
ind = 0
res = 1
while res < t:
	res += a[ind]
	ind = res - 1
print('YES' if res == t else 'NO')


(n, t) = map(int, input().split())
a = map(int, input().split())
visited = [False for _ in range(n)]
matrix = [[] for _ in range(n)]
for (i, aa) in enumerate(a):
	matrix[i].append(i + aa)
visited[0] = True
que = [0]
while que:
	node = que.pop(0)
	if node == t - 1:
		print('YES')
		break
	for nxt in matrix[node]:
		if not visited[nxt]:
			visited[nxt] = True
			que.append(nxt)
else:
	print('NO')


(n, m) = map(int, input().split())
li = list(map(int, input().split()))
k = 1
q = [1]
while k < n:
	k = k + li[k - 1]
	q.append(k)
print('YES' if m in q else 'NO')


(n, t) = list(map(int, input().split()))
arr = list(map(int, input().split()))
graph = {}
for i in range(1, n):
	graph[i] = i + arr[i - 1]
x = 1
while graph.get(x) != t:
	if x not in graph:
		break
	x = graph[x]
if graph.get(x) == t:
	print('YES')
else:
	print('NO')


import collections

def dfs_iter(graph, s, t):
	visited = [False] * len(graph)
	stack = collections.deque()
	stack.append(s)
	while stack:
		v = stack.pop()
		if not visited[v]:
			if v == t:
				return True
			visited[v] = True
			for w in graph[v]:
				if not visited[w]:
					stack.append(w)
	return False
(n, t) = map(int, input().split())
a = map(int, input().split())
graph = [[] for _ in range(n)]
for (i, a_i) in enumerate(a):
	graph[i].append(i + a_i)
res = dfs_iter(graph, 0, t - 1)
print('YES' if res else 'NO')


(n, t) = list(map(int, input().split()))
city = list(map(int, input().split()))
portal = []
for i in range(n - 1):
	portal.append(i + 1)
r = 1
u = 0
flag = False
while u <= n:
	if t < u:
		print('NO')
		break
	elif t == u + 1 and (not flag):
		print('YES')
		break
	elif t == u:
		print('YES')
		break
	flag = True
	u += city[u - 1]


cells_cell = input()
list_cells_cell = cells_cell.split(' ')
cell = int(list_cells_cell[1])
line = input()
list_line = line.split(' ')
list_line = [int(i) for i in list_line]
i = 0
stop = 0
while i < len(list_line):
	i = i + list_line[i]
	if cell == i + 1:
		stop = 1
		break
if stop == 1:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
portals = list(map(int, input().split()))
current = 1
while current < t:
	current += portals[current - 1]
if current == t:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
p = [0] + l
rez = 1 + p[1]
while rez < m:
	rez = p[rez] + rez
if rez == m:
	print('YES')
else:
	print('NO')


(n, t) = [int(x) for x in input().split()]
a = [0] + [int(x) for x in input().split()]
cur = 1
while cur < t:
	cur = cur + a[cur]
print(['NO', 'YES'][cur == t])


(n, x) = map(int, input().split())
a = list(map(int, input().split()))
i = 0
while i < x - 1:
	i = a[i] + i
if x == i + 1:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
inp = list(map(int, input().split()))
l = []
l.append(-1)
for i in inp:
	l.append(i)
i = 1
flag = 0
while i < n:
	if i == k:
		flag = 1
		print('YES')
		break
	flag = 0
	i = i + l[i]
if i >= n and i == k:
	flag = 1
	print('YES')
if flag == 0:
	print('NO')


(n, t) = map(int, input().split())
l = list(map(int, input().split()))
k = 1
flag = 0
i = 0
while k != t and i < n:
	if k > t:
		flag = -1
		break
	else:
		k += l[i]
		i = k - 1
if flag == 0:
	print('YES')
else:
	print('NO')


(n, m) = [int(x) for x in input().split()]
a = list(map(int, input().split()))
d = 0
while d < m - 1:
	d += a[d]
if d == m - 1:
	print('YES')
else:
	print('NO')


def is_transport_possible(t, portals):
	i = 1
	while True:
		i += portals[i - 1]
		if i == t:
			return 'YES'
		if i > t:
			return 'NO'
	return 'NO'
(n, t) = map(int, input().split())
portals = list(map(int, input().split()))
print(is_transport_possible(t, portals))


import sys
inp = [int(i) for i in input().split()]
ni = [int(i) for i in input().split()]
k = 1
while k <= len(ni):
	k = k + ni[k - 1]
	if k == inp[1]:
		print('YES')
		sys.exit(0)
print('NO')


(n, t) = map(int, input().split())
lis = []
[lis.append(int(i)) for i in input().split()]
check = True
j = lis[0]
while check:
	if j + 1 == t:
		print('YES')
		check = False
	elif j >= n - 1:
		print('NO')
		check = False
	else:
		j += lis[j]
		if j + 1 == t:
			print('YES')
			check = False
		if j + 1 > t:
			print('NO')
			check = False


(n, t) = list(map(int, input().split()))
a = list(map(int, input().split()))
a.insert(0, 1)
current = 0
connected = False
for i in range(n):
	current = current + a[current]
	if current == t:
		connected = True
		break
	elif current == n:
		break
if connected:
	print('YES')
else:
	print('NO')


def main():
	(n, t) = map(int, input().split())
	arr = list(map(int, input().split()))
	p = 0
	for i in range(n):
		if i == p:
			p += arr[i]
			if p >= t - 1:
				break
	print('YES' if p == t - 1 else 'NO')
main()


li = list(map(int, input().split()))
n = li[0]
k = li[1]
l = list(map(int, input().split()))
p = 0
while p < k - 1:
	p += l[p]
if p == k - 1:
	print('YES')
else:
	print('NO')


(m, n) = map(int, input().split())
a = [int(x) for x in input().split()]
c = 0
flag = 0
while c < n:
	if c == n - 1:
		print('YES')
		flag = 1
		break
	c += a[c]
if flag == 0:
	print('NO')


from collections import defaultdict, deque, Counter, OrderedDict
import threading, sys

def main():
	(n, t) = map(int, input().split())
	t -= 1
	tog = [int(i) for i in input().split()]
	vis = [0] * n

	def dfs(a):
		if vis[a]:
			return
		vis[a] = 1
		if a < n - 1:
			dfs(a + tog[a])
	dfs(0)
	print('YES' if vis[t] else 'NO')
sys.setrecursionlimit(400000)
threading.stack_size(40960000)
thread = threading.Thread(target=main)
thread.start()


__author__ = 'niketanrane'

class Graph:

	def __init__(self, nodes):
		self.nodes = nodes
		self.vec = [[] for _ in range(self.nodes + 1)]

	def addEdge(self, src, dest):
		self.vec[src].append(dest)
		return

	def BFS(self, src, dest):
		queue = [src]
		visited = [False] * (self.nodes + 1)
		visited[src] = True
		while queue:
			cur = queue.pop(0)
			if cur == dest:
				print('YES')
				return
			for node in self.vec[cur]:
				if not visited[node]:
					visited[node] = True
					queue.append(node)
		print('NO')
(n, m) = map(int, input().split())
gr = Graph(n)
for (index, x) in enumerate(map(int, input().split())):
	gr.vec[index + 1].append(index + 1 + x)
gr.BFS(1, m)


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
c = 0
i = 1
k = 0
while k < len(a):
	i = i + a[k]
	if i == t:
		c = 1
		break
	elif i > t:
		break
	k = i - 1
if c == 1:
	print('YES')
elif c == 0:
	print('NO')


p = list(map(int, input().split()))
x = list(map(int, input().split()))
i = 1
while True:
	if i == p[1]:
		print('YES')
		break
	if i == p[0]:
		print('NO')
		break
	i += x[i - 1]


(n, t) = input().split()
n = int(n)
t = int(t) - 1
a = input().split()
for i in range(len(a)):
	a[i] = int(a[i])
p = 0
while p < t:
	p += a[p]
if p == t:
	print('YES')
else:
	print('NO')


k = lambda : map(int, input().split())
(n, t) = k()
(*l,) = k()
s = 0
while s < n - 1:
	s += l[s]
	if s == t - 1:
		print('YES')
		break
else:
	print('NO')


(n, t) = map(int, input().split())
way = list(map(int, input().split()))
aux = False
e = 0
while e < t:
	e += way[e]
	if e == t - 1:
		aux = True
		break
if aux:
	print('YES')
else:
	print('NO')


import sys
read = lambda : sys.stdin.readline().strip()
write = lambda x: sys.stdout.write(str(x) + '\n')
(n, t) = map(int, read().split())
rels = [int(i) for i in read().split()]
cursor = 0
while True:
	nxt = rels[cursor]
	if cursor + nxt == t - 1:
		ans = 'YES'
		break
	if cursor + nxt > n - 1 or cursor + nxt > t - 1:
		ans = 'NO'
		break
	cursor += nxt
sys.stdout.write(ans)


(totnum, goal) = [int(x) for x in input().split()]
room = [int(x) for x in input().split()]
check = 0
des = []
i = 1
des.append(1)
while i <= totnum - 1:
	i += room[i - 1]
	des.append(i)
for j in range(len(des)):
	if goal == des[j]:
		check += 1
if check >= 1:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
(s, d) = (0, 0)
while s < m:
	s = s + a[s - 1]
	if s == m:
		print('YES')
		d = 1
if d == 0:
	print('NO')


(n, t) = map(int, input().split())
portal = input().split()
wrong = 0
cell = 1
while True:
	if cell < n:
		cell = cell + int(portal[cell - 1])
		if cell == t:
			print('YES')
			break
	else:
		print('NO')
		break


tmp = input().split()
n = int(tmp[0])
t = int(tmp[1]) - 1
portals = []
lista = input().split()
for i in map(int, lista):
	portals.append(i)
portals.append(0)
index = 0
for i in range(n):
	if index > t:
		print('NO')
		break
	elif index == t:
		print('YES')
		break
	else:
		index += portals[index]


(n, d) = map(int, input().split())
arr = [0] + list(map(int, input().split()))
cnt = 1
while cnt <= n and cnt <= d:
	if cnt == d:
		print('YES')
		break
	else:
		cnt += arr[cnt]
else:
	print('NO')


import sys
(n, t) = map(int, sys.stdin.readline().split())
portals = list(map(int, sys.stdin.readline().split()))
cell = 1
while cell < t:
	cell += portals[cell - 1]
if cell == t:
	print('YES')
else:
	print('NO')


(n, t) = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
p = 0
while p < t - 1:
	p = p + c[p]
if p == t - 1:
	print('YES')
else:
	print('NO')


(n, t) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
now = 0
result = 0
while now < n - 1:
	now += a[now]
	if now + 1 == t:
		result = 1
if result:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
l = list(map(int, input().split()))
ind = 1
flag = 0
while ind < n:
	ind = ind + l[ind - 1]
	if ind == t:
		flag = 1
		break
if flag == 1:
	print('YES')
else:
	print('NO')


def main():
	(n, t) = map(int, input().split())
	a = [0] + list(map(int, input().split())) + [100000]
	d = {}
	for i in range(1, n):
		d[i] = i + a[i]
	reached = True
	i = 1
	count = 1
	while reached and count <= 100009:
		if i in d:
			if d[i] == t:
				print('YES')
				exit()
			i = d[i]
			count += 1
		else:
			break
	print('NO')
main()


import math

def solve():
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	i = 0
	while i < m - 1:
		i += l[i]
	if i == m - 1:
		print('YES')
	else:
		print('NO')
t = 1
for i in range(t):
	solve()


(n, m) = map(int, input().split())
l = [int(s) for s in input().split()]
k = 0
i = 1
sum1 = 0
while i < n:
	sum1 = i + l[i - 1]
	if sum1 == m:
		print('YES')
		k = 1
		break
	i = sum1
if k == 0:
	print('NO')


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
g = []
for _ in range(n):
	g.append([])
for i in range(n - 1):
	g[i].append(i + a[i])
used = [0] * n
used[0] = 1
queue = [0]

def bfs():
	while queue != []:
		for v in g[queue[0]]:
			if used[v] == 0:
				queue.append(v)
				used[v] = 1
		del queue[0]
bfs()
if used[t - 1] == 1:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
A = list(map(int, input().split()))
s = 1
while s < n + 1:
	if s == t:
		print('YES')
		break
	elif s == n:
		print('NO')
		break
	else:
		pass
	s = s + A[s - 1]


(n, t) = map(int, input().split())
li = [int(x) for x in input().split()]
pos = 1
flag = False
i = 0
while flag == False:
	if pos == t:
		flag = True
		break
	else:
		pos = pos + li[pos - 1]
	if pos >= n and pos != t:
		break
if flag:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
portal = list(map(int, input().split()))
location = 1
b = 0
while location < t:
	location += portal[location - 1]
	if location == t:
		b = 1
if b == 0:
	print('NO')
else:
	print('YES')


(n, t) = map(int, input().split())
l = list(map(int, input().split()))
su = 1
i = 0
a = 0
while su <= t:
	su += l[i]
	if su == t:
		print('YES')
		a = 1
		break
	i += l[i]
if a == 0:
	print('NO')


(n, goal) = list(map(int, input().split(' ')))
transp = list(map(int, input().split(' ')))
possible = False
i = 0
while True:
	if transp[i] + i + 1 == goal:
		possible = True
		break
	elif transp[i] + i + 1 < goal:
		i = transp[i] + i
	else:
		break
print('YES' if possible else 'NO')


s = str(input()).split()
n = int(s[0])
t = int(s[1])
s = str(input()).split()
a = [int(ss) for ss in s]
current = 1
while True:
	if current == t:
		print('YES')
		break
	elif current >= n:
		print('NO')
		break
	else:
		current += a[current - 1]


(n, t) = map(int, input().split())
meta_data = {n: -1}
stack = [1]
for (i, a) in enumerate(input().split()):
	meta_data[i + 1] = int(a) + i + 1
while 1:
	node = stack.pop()
	if node == t:
		print('YES')
		exit()
	elif node == -1:
		print('NO')
		exit()
	stack.append(meta_data[node])


(n, t) = map(int, input().split())
a = map(int, input().split())
visitable = [1]
portals = {}
c = 1
for i in a:
	v = c + i
	portals[c] = v
	c = c + 1
while len(visitable) != 0:
	if t in visitable:
		print('YES')
		exit()
	try:
		visitable.append(portals[visitable.pop(0)])
	except KeyError:
		continue
print('NO')


(n, t) = [int(x) for x in input().split()]
transport = [int(x) for x in input().split()]
portal = {}
locate = 1
for i in range(n - 1):
	portal[i + 1] = transport[i]
while locate != t and locate < n:
	locate += portal[locate]
if locate == t:
	print('YES')
else:
	print('NO')


(N, t) = list(map(lambda x: int(x), input().strip().split()))
a = list(map(lambda x: int(x), input().strip().split()))
V = {-1}
j = 0
i = 0
while i < N:
	i = a[j] + j + 1
	j = i - 1
	V.add(i)
	if i == t:
		print('YES')
		break
else:
	print('NO')


import sys
(n, t) = list(map(int, sys.stdin.readline().rstrip().split(' ')))
s = list(map(int, sys.stdin.readline().rstrip().split(' ')))
N = {}
for i in range(1, n):
	N[i] = i + s[i - 1]
queue = [1]
while queue:
	ver = queue.pop()
	if ver == t:
		print('YES')
		break
	elif ver in N:
		queue.append(N[ver])
else:
	print('NO')


(n, t) = map(int, input().split())
moves = list(map(int, input().split()))
portals = {}
for i in range(n - 1):
	dest = i + moves[i]
	portals[i + 1] = dest + 1
cur = 1
path = set([cur])
while cur in portals:
	cur = portals[cur]
	path.add(cur)
if t in path:
	print('YES')
else:
	print('NO')


import sys

def ii():
	return sys.stdin.readline().strip()

def idata():
	return [int(x) for x in ii().split()]

def solve_of_problem():
	(n, t) = idata()
	data = idata()
	ans = 1
	while ans != n and ans != t:
		ans += data[ans - 1]
	if ans == t:
		print('YES')
		return
	print('NO')
	return
for ______ in range(1):
	solve_of_problem()


def test():
	(n, t) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	p = 0
	while p < t - 1:
		p += a[p]
	if p == t - 1:
		return 'YES'
	else:
		return 'NO'
print(test())


[n, t] = [int(x) for x in input().split()]
portals = [x for x in input().split()]
paths = {}
i = 1
for portal in portals:
	paths[str(i)] = str(int(portal) + i)
	i += 1
node = '1'
j = 0
while node in paths.keys() and j < len(portals):
	node = paths[node]
	j += 1
	if node == str(t):
		print('YES')
		exit()
print('NO')


n = input().split()
(n, t) = (int(n[0]), int(n[1]))
store = list(map(int, input().split()))
curr = 1 + store[0]
possible = False
while curr <= len(store) and curr < t:
	curr += store[curr - 1]
if curr == t:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
a = input().split()
i = 1
data = []
while i <= n:
	data += [i]
	if i == n:
		break
	else:
		i += int(a[i - 1])
for i in data:
	if t == i:
		print('YES')
		break
else:
	print('NO')


line = [int(i) for i in input().split()]
n = line[0]
goal = line[1]
path = [int(i) for i in input().split()]
my_position = 0
while my_position < n - 1:
	my_position = path[my_position] + my_position
	if my_position + 1 == goal:
		print('Yes')
		my_position = -1
		break
if my_position != -1:
	print('NO')


(n, t) = map(int, input().split())
l = map(int, input().split())
r = [i + j + 1 for (i, j) in enumerate(l)]
s = 1
while True:
	s = r[s - 1]
	if t == s:
		print('YES')
		break
	elif s > t:
		print('NO')
		break


t = int(input().split()[1])
v = [int(x) for x in input().split()]
i = 0
while i < t - 1:
	i += v[i]
if i == t - 1:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
L = list(map(int, input().split()))
flag = 0
k -= 1
p = 0
while p < k:
	p += L[p]
if p == k:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
visited = [1]
s = 1
while s <= n - 1:
	s += a[s - 1]
	visited.append(s)
if t in visited:
	print('YES')
else:
	print('NO')


(m, n) = [int(x) - 1 for x in input().split()]
l = [int(x) for x in input().split()]
cur = 0
while cur < m:
	if n == cur:
		print('YES')
		exit()
	cur += l[cur]
print('NO' if n != cur else 'YES')


def check(i):
	while i < k:
		i += h[i]
	if i == k:
		print('YES')
	else:
		print('NO')
(n, k) = map(int, input().split())
h = list(map(int, input().split()))
h = [0] + h
check(1)


i = input
(n, t) = map(int, i().split())
s = list(map(int, i().split()))
s.append(1)
(p, x) = (1, 0)
while True:
	if p <= n:
		p += s[p - 1]
	else:
		break
	if p == t:
		print('YES')
		exit()
print('NO')


(n, t) = map(int, input().split())
cells = list(map(int, input().split()))
cont = 0
i = 0
while i < t - 1:
	cont += cells[i]
	i += cells[i]
if cont == t - 1:
	print('YES')
else:
	print('NO')


(n, p) = map(int, input().split())
a = [i + 1 + x for (i, x) in enumerate(map(int, input().split()))]
x = a[0]
while x < n:
	if x == p:
		break
	x = a[x - 1]
print('YES' if x == p else 'NO')


global cells, t
(n, t) = map(int, input().split())
cells = list(map(int, input().split()))
cells.insert(0, None)

def dfs(v):
	global cells, t
	while v + cells[v] <= t:
		if v + cells[v] == t:
			return True
		v = v + cells[v]
	return False
ans = dfs(1)
if ans:
	print('YES')
else:
	print('NO')


x1 = input().split(' ')
x2 = [int(k) for k in input().split(' ')]
length = int(x1[0])
target = int(x1[1])
eachtarget = {}
for i in range(1, length):
	eachtarget[i] = i + x2[i - 1]
stack = [1]
thisset = set()
thisset.add(1)
queue = [1]
finish = False
while queue != []:
	cur = queue.pop()
	if cur == target:
		print('YES')
		finish = True
		break
	else:
		if cur not in eachtarget:
			print('NO')
			finish = True
			break
		nextcur = eachtarget[cur]
		if nextcur not in thisset:
			queue.append(nextcur)
		else:
			break
if stack == [] and finish == False:
	print('NO')


from collections import defaultdict
import sys
sys.setrecursionlimit(65536)

class Graph:

	def __init__(self):
		self.graph = defaultdict(list)

	def addEdge(self, u, v):
		self.graph[u].append(v)

	def DFSUtil(self, v, visited, key):
		visited[v] = True
		if v == key:
			print('YES')
			sys.exit(0)
		for i in self.graph[v]:
			if i <= len(self.graph) and visited[i] == False:
				self.DFSUtil(i, visited, key)

	def DFS(self, v, key):
		visited = [False] * len(self.graph)
		self.DFSUtil(v, visited, key)
g = Graph()
(n, k) = map(int, input().split())
b = [1]
arr = list(map(int, input().split()))
b.extend(arr)
b.append(1)
i = 1
while i < k:
	i += b[i]
if i == k:
	print('YES')
else:
	print('NO')


def check(a, t):
	i = 1
	while i < t:
		i += a[i - 1]
	if i == t:
		return 'YES'
	return 'NO'
(n, t) = map(int, input().strip().split())
a = list(map(int, input().strip().split()))
print(check(a, t))


z = input().split()
(l, target) = (int(z[0]), int(z[1]) - 1)
data = [int(k) for k in input().split()]
x = 0
while x <= target:
	if x != target:
		x += data[x]
	else:
		print('YES')
		x = l + 1
if x != l + 1:
	print('NO')


(n, x) = map(int, input().split())
N = [int(num) for num in input().split(' ', n - 1)]
i = 1
X = 0
while i <= x:
	i = i + N[i - 1]
	if i == x:
		X = 1
		break
if X == 1:
	print('YES')
else:
	print('NO')


(n, t) = [int(x) for x in input().split()]
a = [int(y) for y in input().split()]
p = 1
while p <= n:
	p += a[p - 1]
	if p == t:
		print('YES')
		break
	elif p == n:
		print('NO')
		break
	else:
		pass


(n, d) = map(int, input().split())
ar = [0]
ar.extend(list(map(int, input().split())))
i = 1
dp = [False] * (n + 1)
dp[1] = True
j = 0
while i < n:
	i = i + ar[i]
	dp[i] = True
if dp[d]:
	print('YES')
else:
	print('NO')


line = input()
n = int(line.split()[0])
t = int(line.split()[1])
line1 = [int(i) for i in input().split()]
line2 = list(range(1, n + 1))
a = 1
b = 1
for i in range(n):
	a += line1[b - 1]
	b = line2[a - 1]
	if a < t:
		continue
	if a == t:
		print('YES')
		break
	if a > t:
		print('NO')
		break


import sys
sys.setrecursionlimit(10 ** 9)
(n, m) = map(int, input().split())
arr = [int(i) for i in input().split()]
i = 0
while i <= m - 1:
	if i == m - 1:
		print('YES')
		break
	i += arr[i]
else:
	print('NO')


(n, t) = [int(y) for y in input().split()]
l = [int(x) for x in input().split()]
count = 0
while True:
	count += l[count]
	if count + 1 == t:
		print('YES')
		break
	elif count + 1 > t:
		print('NO')
		break


(cells, destination) = list(map(int, input().split()))
cell_value = list(map(int, input().split()))
current_cell = 0
while current_cell < cells:
	current_cell += cell_value[current_cell]
	if current_cell + 1 == destination:
		print('YES')
		break
	elif current_cell + 1 > destination:
		print('NO')
		break


(n, t) = input().split(' ')
(n, t) = (int(n), int(t))
n_1 = list(map(int, input().split()))
l = {}
j = 0
for i in n_1:
	j += 1
	l[j] = i + j
i = 1
j = True
while j:
	if i == t:
		print('YES')
		j = False
	elif i > t:
		print('NO')
		j = False
	else:
		i = l[i]


(n, ind) = map(int, input().split())
L = [int(i) for i in input().split()]
flag = 0
q = 1
while q < n:
	q += L[q - 1]
	if q == ind:
		flag = 1
if flag == 0:
	print('NO')
else:
	print('YES')


(m, n) = map(int, input().split())
ls = list(map(int, input().split()))
path = list([0 for i in range(m - 1)])
i = 0
p = 1
pp = []
while p not in pp:
	pp.append(p)
	i = p + ls[i] - 1
	if i >= m - 1:
		i = m - i - 1
	path[i] = p
	p = i + 1
s = 1
if n == m:
	s = n
print('YES' if path[n - s] != 0 else 'NO')


import sys
NT = list(map(int, input().split()))
A = list(map(int, input().split()))
Count = 0
for I in range(NT[0]):
	Count += A[Count]
	if Count > NT[1] - 1:
		print('NO')
		sys.exit()
	if Count == NT[1] - 1:
		print('YES')
		sys.exit()
	if not A[Count]:
		print('NO')


(n, t) = [int(i) for i in input().split(' ')]
line = [int(i) for i in input().split(' ')]
i = 0
flag = 1
while i != t - 1:
	if i >= len(line):
		print('NO')
		flag = 0
		break
	i = i + line[i]
if flag:
	print('YES')


(n, m) = map(int, input().split(' '))
ar = [int(i) for i in input().split(' ')]
sumAr = 1
i = 0
while sumAr < m:
	sumAr += ar[sumAr - 1]
if sumAr == m:
	print('YES')
else:
	print('NO')


entrada = input().split()
n = int(entrada[0])
t = int(entrada[1])
adjacencias = input().split()
adjacencias.insert(0, '0')
i = 1
chegou = False
while i < len(adjacencias):
	i = i + int(adjacencias[i])
	if i == t:
		chegou = True
		break
if chegou:
	print('YES')
else:
	print('NO')


def solve():
	i = 1
	while i < t:
		i += arr[i - 1]
	if i == t:
		return 'YES'
	else:
		return 'NO'
(n, t) = map(int, input().split())
arr = list(map(int, input().split()))
print(solve())


(n, t) = map(int, input().split())
A = list(map(int, input().split()))
pos = 0
t -= 1
while pos < t:
	pos += A[pos]
if pos == t:
	print('YES')
else:
	print('NO')


(n, t) = [int(x) for x in input().split()]
a = [0] + [int(x) for x in input().split()]
current_cell = 1
succes = False
echec = False
if n == t:
	succes = True
while not succes and (not echec) and (current_cell < n):
	if current_cell == t:
		succes = True
		break
	elif current_cell < t:
		current_cell += a[current_cell]
	else:
		echec = 1
if succes:
	print('YES')
else:
	print('NO')


def fun(l, n, t):
	l.insert(0, 0)
	i = 1
	while i < n:
		i = i + l[i]
		if i == t:
			return 'YES'
	return 'NO'
(n, t) = [int(x) for x in list(input().split())]
l = list(map(int, input().split()))
print(fun(l, n, t))


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
a.insert(0, 0)
truth = False
counter = 1
while counter < len(a):
	if counter == t:
		truth = True
		break
	counter += a[counter]
if counter == t:
	truth = True
print('YES') if truth else print('NO')


import sys
sys.setrecursionlimit(30000)
try:
	(n, t) = map(int, input().split())
	temp = [int(i) for i in input().split()]
	sorted_edges = [[] for _ in range(n)]
	for i in range(n - 1):
		if temp[i] + i <= t:
			sorted_edges[temp[i] + i].append(i + 1)
	pos = t
	test_cases = [pos]
	test_cases_copy = []
	while test_cases != []:
		for current_pos in test_cases:
			if current_pos == 1:
				print('YES')
				exit()
			for num in sorted_edges[current_pos - 1]:
				test_cases_copy.append(num)
		test_cases = test_cases_copy
		test_cases_copy = []
	print('NO')
except Exception as e:
	print(e)


def solve(arr, destination):
	current = 1
	while current <= destination:
		if current == destination:
			return 'YES'
		current += arr[current - 1]
	return 'NO'
f = lambda : list(map(int, input().split()))
(n, t) = f()
print(solve(f(), t))


(n, t) = [int(x) for x in input().split(' ')]
world = [int(x) for x in input().split(' ')]
v = 0
while v < t - 1:
	v = world[v] + v
if v == t - 1:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
c = 0
i = 0
while i < n:
	if i + 1 == k:
		print('YES')
		exit()
	if i + 1 > k:
		print('NO')
		exit()
	i += a[i]


s = input().split(' ')
n = int(s[0])
target = int(s[1])
s1 = input().split(' ')
portal = [0] * (n - 1)
for i in range(n - 1):
	portal[i] = int(s1[i])
position = 1
flag = False
while position <= target:
	position += portal[position - 1]
	if position == target:
		flag = True
		break
if flag:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
a = [0] + [int(x) for x in input().split()] + [0]
ans = False
q = []
q.append(1)
visited = [False for _ in range(n + 2)]
visited[1] = True
while q:
	s = q.pop(0)
	if s == t:
		ans = True
		break
	if not visited[s + a[s]]:
		q.append(s + a[s])
		visited[s + a[s]] = True
if visited[t]:
	ans = True
print('YES' if ans else 'NO')


def f():
	(n, tar) = input().split(' ')
	n = int(n)
	tar = int(tar) - 1
	l = list(map(int, input().split(' ')))
	i = 0
	while i < n - 1:
		i = i + l[i]
		if i == tar:
			print('YES')
			return
	print('NO')
f()


(n, t) = map(int, input().split())
arr = list(map(int, input().split()))
ans = [False] * n
ans[0] = True
ctr = 0
while ctr < n:
	try:
		ans[ctr] = True
		ctr += arr[ctr]
	except IndexError:
		break
if ans[t - 1]:
	print('YES')
else:
	print('NO')


import sys
an = list(map(int, input().split()))
p = list(map(int, input().split()))
t = 1
while t < an[1]:
	t = t + p[t - 1]
	if t == an[1]:
		print('YES')
		sys.exit()
print('NO')


(a, b) = map(int, input().split())
l = list(map(int, input().split()))
c = 1
while c < a:
	c += l[c - 1]
	if c == b:
		print('YES')
		break
else:
	print('NO')


(n, t) = list(map(int, input().split()))
a = list(map(int, input().split()))
curr = 1
visited = False
while curr <= t:
	if curr == t:
		visited = True
		break
	curr = curr + a[curr - 1]
if visited:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split(' '))
matrix = {}
lis = list(map(int, input().split(' ')))
for i in range(len(lis)):
	matrix[i] = lis[i] + i
visited = [False for i in range(n)]
visited[0] = True
q = [0]
while q:
	idx = q.pop(0)
	if idx in matrix:
		nei = matrix[idx]
		visited[nei] = True
		q.append(nei)
if visited[t - 1]:
	print('YES')
else:
	print('NO')


x = list(map(int, input().split()))
n = list(map(int, input().split()))
r = 1
while r <= x[1]:
	if r == x[1]:
		print('YES')
		exit()
	elif r == x[0] and x[0] == x[1]:
		print('YES')
		exit()
	r += n[r - 1]
print('NO')


__author__ = 'Bian'
(n, ind) = [int(x) for x in input().split()]
portal = [int(x) for x in input().split()]
portal.insert(0, 0)
i = 1
while i <= n:
	if i == ind:
		print('YES')
		break
	if i + portal[i] > ind:
		print('NO')
		break
	i += portal[i]


x = list(map(int, input().split()))
y = list(map(int, input().split()))
n = x[0]
t = x[1] - 1
p = 0
lokasi = 0
while p < t:
	if lokasi == p:
		p += y[lokasi]
	lokasi += 1
if p == t:
	print('YES')
else:
	print('NO')


a = list(map(int, input().split()))
L = list(map(int, input().split()))
i = 1
t = 0
while t != 1 and i <= len(L):
	i = L[i - 1] + i
	if i == a[1]:
		t = 1
if t == 0:
	print('No')
else:
	print('Yes')


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
d = dict()
for i in range(n - 1):
	d[i + 1] = i + 1 + l[i]
pos = 1
if k == 1:
	print('YES')
	exit(0)
while pos < n:
	pos = d[pos]
	if pos == k:
		print('YES')
		exit(0)
print('NO')


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
now = 1
while now < k:
	now += a[now - 1]
if now == k:
	print('YES')
else:
	print('NO')


import copy
list_ = []
temp = []
numb_list = [None]
nachalo = 1
vhod = input()
vhod_list = vhod.split()
number = int(vhod_list[0])
propast = int(vhod_list[1])
vhod = input()
vhod_list = vhod.split()
for it in vhod_list:
	numb_list.append(int(it))
it = 1
while it < len(numb_list):
	if propast == it + numb_list[it]:
		print('YES')
		break
	it = it + numb_list[it]
if it >= len(numb_list):
	print('NO')


def _500A(t, n, a):
	position = 1
	position_list = [1]
	while position < n:
		position = position + a[position - 1]
		position_list.append(position)
	return 'YES' if t in position_list else 'NO'
(n, t) = list(map(lambda x: int(x), input().split()))
a = list(map(lambda x: int(x), input().split()))
print(_500A(t, n, a))


l = list(map(int, input().split()))
b = [int(i) for i in input().split()]
a = ['']
a.extend(b)
(f, flag) = (1, 0)
(n, t) = (l[0], l[1])
for i in range(len(a)):
	if f > len(a) - 1:
		break
	f = f + a[f]
	if f == t:
		print('YES')
		flag = 1
		break
if flag == 0:
	print('NO')


(n, m) = map(int, input().split())
s = list(map(int, input().split()))
i = 1
x = 'NO'
while i < m:
	i += s[i - 1]
	if i == m:
		x = 'YES'
print(x)


(n, t) = map(int, input().split())
l = list(map(int, input().split()))
l = [0] + l
i = 1
f = True
while i < len(l):
	i = i + l[i]
	if i == t:
		print('YES')
		f = False
		break
if f:
	print('NO')


currentPos = 1
finish = False
fl = ''
sl = ''
fl = input()
sl = input()
fls = fl.split(' ')
cellnumbers = int(fls[0])
finishcell = int(fls[1])
sls = sl.split(' ')
portales = []
portales.append(-1)
for l in sls:
	portales.append(int(l))
for n in range(0, cellnumbers):
	if currentPos == finishcell:
		print('yes')
		finish = True
		break
	elif currentPos > finishcell:
		print('no')
		finish = True
		break
	else:
		currentPos += portales[currentPos]
if not finish:
	print('no')


(n, t) = map(int, input().split())
l = input().split()
l = [int(x) for x in l]
resp = 'NO'
if t == 1:
	resp = 'YES'
else:
	i = 1
	while i <= n - 1:
		if i + l[i - 1] == t:
			resp = 'YES'
		i += l[i - 1]
print(resp)


fl = list(map(int, input().split()))
sl = list(map(int, input().split()))
myLocation = 1
for i in range(1, fl[0]):
	myLocation = myLocation + sl[myLocation - 1]
	if myLocation == fl[1]:
		print('YES')
		break
	elif myLocation > fl[1]:
		print('NO')
		break


(n, t) = map(int, input().split())
list_a = list(map(int, input().split()))
trans = list_a[0] + 1
while trans < t:
	trans += list_a[trans - 1]
if trans == t:
	print('YES')
else:
	print('NO')


def enterPortal(cells, pos, target):
	while pos < target:
		pos += cells[pos]
	if pos == target:
		return 'YES'
	else:
		return 'NO'
(n_cells, target) = [int(x) for x in input().split()]
cells = [int(x) for x in input().split()]
print(enterPortal(cells, 0, target - 1))


(n, t) = map(int, input().strip().split()[:2])
l = list(map(int, input().strip().split()[:n - 1]))
k = 0
while k < n - 1:
	k = l[k] + k
	if k == t - 1:
		print('YES')
		break
else:
	print('NO')


m = int(input().split()[1])
k = [0] + list(map(int, input().split()))
i = 1
while i < m:
	i = i + k[i]
if m == i:
	print('YES')
else:
	print('NO')


(nodes, destination) = list(map(int, input().split()))
sucesion = list(map(int, input().split()))
graph = {x: set() for x in range(1, nodes + 1)}
for i in range(1, 1 + len(sucesion)):
	to = i + sucesion[i - 1]
	graph[i].add(to)

def dfs(graph, start):
	(visited, stack) = (set(), [start])
	while stack:
		parent = stack.pop()
		visited.add(parent)
		stack.extend(graph[parent] - visited)
	return visited
print('YES' if destination in dfs(graph, 1) else 'NO')


nt = [int(i) for i in input().split()]
a = [0] + [int(i) for i in input().split()]
b = [1]
i = 1
while b[-1] < nt[0]:
	i += a[i]
	b.append(i)
if nt[1] in b:
	print('YES')
else:
	print('NO')


import collections
_input = [int(num) for num in input().split(' ')]
num_cells = _input[0]
cell_index = _input[1]
a_numbers = [int(num) for num in input().split(' ')]
portals = [num for num in range(1, num_cells)]
transportation_system = collections.defaultdict(int)
for portal in portals:
	transportation_system[portal] = portal + a_numbers[portal - 1]
is_possible = False
cell = 1
while cell in transportation_system:
	if cell == cell_index or transportation_system[cell] == cell_index:
		is_possible = True
		break
	elif cell > cell_index:
		break
	cell = transportation_system[cell]
if is_possible:
	print('YES')
else:
	print('NO')


(_, a) = map(int, input().split())
b = list(map(int, input().split()))
c = []
i = 0
while i < len(b):
	c.append(i + 1)
	i += b[i]
	c.append(i + 1)
print('YNEOS'[0 if a in c else 1::2])


(n, t) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
cell_passed = [a[0] + 1]
resp = 'NO'
if cell_passed[0] != t:
	for i in range(1, n - 1):
		source = i + 1
		target = a[i] + source
		if cell_passed[len(cell_passed) - 1] == source:
			if target == t:
				resp = 'YES'
				break
			cell_passed.append(target)
else:
	resp = 'YES'
print(resp)


(n, m) = map(int, input().split(' '))
cel = input().split(' ')
cel = [int(x) for x in cel]
if m == 1:
	print('YES')
cont = 1
i = 0
while i <= m:
	cont += cel[i]
	if m == cont:
		print('YES')
		break
	elif cont > m:
		print('NO')
		break
	i += cel[i]


(n, t) = map(int, input().split())
l = [0]
l += [int(i) for i in input().split()]
s = set()
i = 1
while i < n:
	i += l[i]
	s.add(i)
print('YNEOS'[t not in s::2])


(n, t) = list(map(int, input().split(' ')))
A = list(map(int, input().split(' ')))
t -= 1
cunt = 1
i = 0
while True:
	if i == t:
		print('YES')
		cunt = 0
		break
	elif i == n - 1:
		break
	else:
		i = A[i] + i
if cunt == 1:
	print('NO')


(n, t) = map(int, input().split())
my_list = list(map(int, input().split()))
current_ind = 0
flag = False
while current_ind < n - 1:
	current_val = my_list[current_ind]
	current_ind += current_val
	if current_ind + 1 == t:
		flag = True
		break
print('YES') if flag else print('NO')


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
curr = -1
i = 1
while i < n:
	curr = arr[i - 1] + i
	i += arr[i - 1]
	if curr == k:
		print('YES')
		break
else:
	print('NO')


import sys
import operator

def solve(xs, n, t):
	dest = list(map(operator.add, range(1, n), xs))
	if t == 1:
		return True
	pos = 1
	while pos < t:
		pos = dest[pos - 1]
		if pos == t:
			return True
	else:
		return False

def tf_to_yn(tf):
	return 'YES' if tf else 'NO'

def print_stderr(*args, **kwargs):
	print(*args, file=sys.stderr, **kwargs)

def main():
	[n, t] = [int(i) for i in input().strip().split()]
	xs = [int(i) for i in input().strip().split()]
	assert len(xs) == n - 1
	result = tf_to_yn(solve(xs, n, t))
	print(result)
main()


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
pos = 1
while pos < t:
	pos += a[pos - 1]
print(('NO', 'YES')[pos == t])


import sys
import math
(n, t) = [int(x) for x in sys.stdin.readline().split()]
an = [int(x) for x in sys.stdin.readline().split()]
i = 1
while i < n:
	if i == t:
		print('YES')
		exit()
	i = i + an[i - 1]
if i == t:
	print('YES')
	exit()
print('NO')


(n, t) = tuple(map(int, input().split()))
a = list(map(int, input().split()))
i = 1
for j in range(1, n):
	if t == 1:
		print('YES')
		break
	else:
		temp = i + a[i - 1]
		i = temp
		if t == i:
			print('YES')
			break
		elif i > n - 1:
			print('NO')
			break


(n, t) = input().split()
(n, t) = (int(n), int(t))
portals = list(map(lambda e: int(e), input().split(' ')))
x = 1
i = 0
if x == t:
	print('YES')
else:
	while x < t:
		x += portals[i]
		i += portals[i]
	if x == t:
		print('YES')
	else:
		print('NO')


(n, t) = list(map(int, input().split()))
arr = list(map(int, input().split()))
z = 1
while z:
	if z + arr[z - 1] <= t:
		z += arr[z - 1]
	else:
		print('NO')
		exit()
	if z == t:
		print('YES')
		exit()


def main():
	(n, t) = input().split()
	(n, t) = (int(n), int(t))
	L = [int(x) for x in input().split()]
	c = 1
	while c < t:
		c += L[c - 1]
	print('YES' if c == t else 'NO')
main()


from collections import defaultdict
from queue import Queue
(n, t) = tuple(map(int, input().split()))
tmp = list(map(int, input().split()))
e = defaultdict(list)
for i in range(n - 1):
	e[i + 1].append(i + 1 + tmp[i])

def bfs(v):
	mark = defaultdict(int)
	q = Queue()
	q.put(v)
	mark[v] = 1
	while not q.empty():
		v = q.get()
		for i in e[v]:
			if i == t:
				return 'YES'
			if mark[i] == 0:
				mark[i] == 1
				q.put(i)
	return 'NO'
print(bfs(1))


(n, m) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = 0
c = [1]
while b < n:
	b = a[b - 1] + b
	c.append(b)
if m in c:
	print('YES')
else:
	print('NO')


(numbercells, target) = map(int, input().split())
clist = list(map(int, input().split()))
clist = [0] + clist
current = 1
while current <= target:
	if current == target:
		print('YES')
		break
	elif current < target:
		current += clist[current]
if current > target:
	print('NO')


(a, b) = input().split()
a = int(a)
b = int(b)
c = input().split()
z = 1
while z < b:
	z += int(c[z - 1])
if z == b:
	print('YES')
else:
	print('NO')


def new_year_transportation(m, s, b):
	p = 1
	while p < t:
		p += b[p - 1]
	if p == t:
		return 'YES'
	else:
		return 'NO'
f = lambda : map(int, input().split())
(n, t) = f()
a = list(f())
print(new_year_transportation(n, t, a))


[n, t] = list(map(int, input().split()))
arr = list(map(int, input().split()))
nxt = 1
while nxt < t:
	nxt += arr[nxt - 1]
if nxt == t:
	print('YES', end='')
else:
	print('NO', end='')


def int_map():
	return map(int, input().split(' '))
(n, t) = int_map()
a = [0] + list(int_map())
i = 1
while i < t:
	i += a[i]
if i == t:
	print('YES')
else:
	print('NO')


line = input().split()
n = int(line[0])
t = int(line[1])
line1 = input()
s = [int(a) for a in line1.split()]
st = 0
count = 1
s1 = []
while st <= len(s) - 1:
	count = count + s[st]
	s1.append(count)
	st = count - 1
if t in s1:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
s = list(input().split())
result = 'NO'
i = 1
found = False
while i < n and found == False:
	ai = int(s[i - 1])
	i += ai
	if i == t:
		result = 'YES'
		found = True
print(result)


(n, t) = input().split()
n = int(n)
t = int(t)
L = input().split()
L = [int(e) for e in L]
cell = 1
while cell < t:
	cell += L[cell - 1]
if cell == t:
	print('YES')
if cell != t:
	print('NO')


(a, b) = map(int, input().split())
c = list(map(int, input().split()))
x = 1
while x < a:
	x += c[x - 1]
	if x == b:
		print('YES')
		quit()
print('NO')


import math
from collections import *
import sys
from functools import reduce

def get_ints():
	return map(int, input().strip().split())

def get_list():
	return list(get_ints())

def get_string():
	return list(input().strip().split())

def printxsp(*args):
	return print(*args, end='')

def printsp(*args):
	return print(*args, end=' ')
UGLYMOD = int(1000000000.0) + 7
SEXYMOD = 998244353
MAXN = int(100000.0)
(n, k) = get_ints()
li = get_list()
visited = [False] * (n + 1)
start = 0
visited[0] = True
while start < k - 1:
	start += li[start]
print('YES' if start == k - 1 else 'NO')


from sys import stdin, stdout
(n, t) = stdin.readline().split()
n = int(n)
t = int(t) - 1
arr = stdin.readline().split()
arr.append('0')
ans = False
idx = 0
while not ans:
	if idx == t:
		ans = True
	if idx == n - 1:
		break
	idx += int(arr[idx])
if ans:
	stdout.write('YES\n')
else:
	stdout.write('NO\n')


(n, m) = list(map(int, input().split()))
l = list(map(int, input().split()))
flag = False
i = 1
while i <= len(l):
	i += l[i - 1]
	if i == m:
		flag = True
if flag:
	print('YES')
else:
	print('NO')


(n, t) = input().split()
n = int(n)
t = int(t)
l = input().split()
i = 1
r = 0
while i < t:
	i = i + int(l[i - 1])
	if i == t:
		print('YES')
		r = 1
		break
if r == 0:
	print('NO')


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import collections as col
import math, string

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
MOD = 10 ** 9 + 7

def solve():
	(N, T) = getInts()
	A = getInts()
	pos = 1
	while True:
		if pos == T:
			return 'YES'
		if pos > T:
			return 'NO'
		pos += A[pos - 1]
print(solve())


def main():
	(n, t) = map(int, input().split())
	t -= 1
	a = list(map(int, input().split()))
	pos = 0
	while pos < t:
		pos += a[pos]
	print('YES' if pos == t else 'NO')
main()


(n, m) = [int(x) for x in input().split()]
q = [int(x) for x in input().split()]
found = False
current = 1
i = 0
while i < n - 1:
	current += q[i]
	i += q[i]
	if i + 1 == m:
		found = True
		break
print('YES' if found else 'NO')


(n, t) = [int(x) for x in input().split()]
ai = [int(x) for x in input().split()]
currentcell = 1
places = [1]
while currentcell < n:
	currentcell += ai[currentcell - 1]
	places.append(currentcell)
print('YES' if t in places else 'NO')


import sys
from bisect import bisect_left, bisect_right, insort
from collections import deque, Counter
from math import gcd, sqrt, factorial, ceil, log10, log2
from itertools import permutations
from heapq import heappush, heappop, heapify
inf = float('inf')
mod = 1000000007

def factorial_p(n, p):
	ans = 1
	if n <= p // 2:
		for i in range(1, n + 1):
			ans = ans * i % p
	else:
		for i in range(1, p - n):
			ans = ans * i % p
		ans = pow(ans, p - 2, p)
		if n % 2 == 0:
			ans = p - ans
	return ans

def nCr_p(n, r, p):
	ans = 1
	while n != 0 or r != 0:
		(a, b) = (n % p, r % p)
		if a < b:
			return 0
		ans = ans * factorial_p(a, p) * pow(factorial_p(b, p), p - 2, p) * pow(factorial_p(a - b, p), p - 2, p) % p
		n //= p
		r //= p
	return ans

def prime_sieve(n):
	flag = n % 6 == 2
	sieve = bytearray((n // 3 + flag >> 3) + 1)
	for i in range(1, int(n ** 0.5) // 3 + 1):
		if not sieve[i >> 3] >> (i & 7) & 1:
			k = 3 * i + 1 | 1
			for j in range(k * k // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
			for j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
	return sieve

def prime_list(n):
	res = []
	if n > 1:
		res.append(2)
	if n > 2:
		res.append(3)
	if n > 4:
		sieve = prime_sieve(n + 1)
		res.extend((3 * i + 1 | 1 for i in range(1, (n + 1) // 3 + (n % 6 == 1)) if not sieve[i >> 3] >> (i & 7) & 1))
	return res

def binary(number):
	result = 0
	while number:
		result = result + 1
		number = number & number - 1
	return result

def is_prime(n):
	if n < 5 or n & 1 == 0 or n % 3 == 0:
		return 2 <= n <= 3
	s = (n - 1 & 1 - n).bit_length() - 1
	d = n >> s
	for a in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]:
		p = pow(a, d, n)
		if p == 1 or p == n - 1 or a % n == 0:
			continue
		for _ in range(s):
			p = p * p % n
			if p == n - 1:
				break
		else:
			return False
	return True

def all_factors(n):
	(small, large) = ([], [])
	for i in range(1, int(n ** 0.5) + 1, 2 if n & 1 else 1):
		if not n % i:
			small.append(i)
			large.append(n // i)
	if small[-1] == large[-1]:
		large.pop()
	large.reverse()
	small.extend(large)
	return small

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
(n, m) = get_ints()
Arr = get_array()
myArr = [False] * (n + 1)
myArr[1] = True
last = 1
while last < n:
	new = last + Arr[last - 1]
	myArr[new] = True
	last = new
if myArr[m] == True:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
t = t - 1
c = list(map(int, input().split()))
c = [c[i] + i for i in range(t)]
current = 0
while current < t:
	current = c[current]
if current == t:
	print('Yes')
else:
	print('No')


(n, t) = map(int, input().split())
a = [0] + list(map(int, input().split()))
cur = 1
if t == 1:
	print('YES')
	exit()
while cur <= t:
	to = cur + a[cur]
	cur = to
	if cur == t:
		print('YES')
		exit()
print('NO')


(m, n) = map(int, input().split())
a = list(map(int, input().split()))
(c, flag) = (0, 0)
while c < n:
	c += a[c]
	if c == n - 1:
		flag = 1
		break
print(['NO', 'YES'][flag == 1])


(n, k) = [int(x) for x in input().split(' ')]
g = [[] for i in range(n)]
a = [int(x) for x in input().split(' ')]
for i in range(len(a)):
	g[i].append(i + a[i])
stack = []
stack.append(0)
f = False
while len(stack):
	v = stack.pop()
	if v == k - 1:
		f = True
	for i in g[v]:
		stack.append(i)
print('YES' if f else 'NO')


li = [int(i) for i in input().split()]
li2 = [int(i) for i in input().split()]
n = li[0]
t = li[1]
li1 = []
li1.append(1)
i = 1 + li2[0]
while i < n:
	li1.append(i)
	s = i + li2[i - 1]
	i = s
li1.append(i)
if t in li1:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
list1 = list(map(int, input().split()))
Bool = 0
count = 1
while count <= n - 1:
	count += list1[count - 1]
	if count == t:
		print('YES')
		Bool = 1
		break
	else:
		continue
if Bool == 0:
	print('NO')


(n, index) = map(int, input().split())
a = list(map(int, input().split()))
visited = set()
next = 1
while True:
	visited.add(next)
	if next >= n:
		break
	next += a[next - 1]
if index in visited:
	print('YES')
else:
	print('NO')


(m, n) = map(int, input().split())
s = list(map(int, input().split()))
A = []
count = 1
i = 0
while count <= len(s):
	count += s[i]
	A.append(count)
	i += s[i]
if n in A:
	print('YES')
else:
	print('NO')


def dfs(node):
	visited[node] = True
	stack = [node]
	while stack:
		a = stack.pop()
		for child in graph[a]:
			if visited[child] == False:
				stack.append(child)
				visited[child] = True
(n, t) = map(int, input().split())
l = list(map(int, input().split()))
l = [0] + l
graph = {}
for i in range(1, n + 1):
	graph[i] = []
for i in range(1, n):
	graph[i].append(l[i] + i)
visited = [False for i in range(n + 1)]
dfs(1)
if visited[t] == True:
	print('YES')
else:
	print('NO')


input1 = input().split()
n = int(input1[0])
goal = int(input1[1])
portals = input().split()
adj_list = [[] for l in range(n)]
loc = 0
for i in range(n):
	loc += int(portals[loc])
	if loc == goal - 1:
		print('YES')
		quit()
	elif loc >= goal:
		print('NO')
		quit()


import sys
(n, t) = map(int, sys.stdin.readline().split())
a_list = list(map(int, sys.stdin.readline().split()))
a_list.insert(0, 0)
x = 1
while True:
	y = a_list[x] + x
	if y == t:
		print('Yes')
		break
	if y > t:
		print('No')
		break
	x = y


(n, t) = map(int, input().split())
v = [int(m) for m in input().split()]
r = list()
index = 0
if len(v) != n - 1 or not (2 <= t <= n and 3 <= n <= 3 * 10 ** 4):
	raise KeyError('Error.')
while index < len(v):
	r.append(index + 1)
	index += v[index]
r.append(index + 1)
print('YES' if t in r else 'NO')


(n, k) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
i = 0
while i < n:
	if i == k - 1:
		print('YES')
		break
	elif i == n - 1:
		i = i + 1
	else:
		i = i + a[i]
else:
	print('NO')


(n, t) = [int(__) for __ in input().strip().split()]
arr = [int(__) for __ in input().strip().split()]
cur = 0
while cur != t - 1 and cur < t - 1:
	cur = arr[cur] + cur
print('YES' if cur == t - 1 else 'NO')


(n, t) = list(map(int, input().split()))
seq = list(map(int, input().split()))
t -= 1
i = 0
while True:
	if i == t:
		print('YES')
		break
	if i > t:
		print('NO')
		break
	i += seq[i]


line = input().split(' ')
n = int(line[0])
t = int(line[1])
cells = [int(a) for a in input().split(' ')]
cell_index = 0
while cell_index < t - 1:
	cell_index += cells[cell_index]
if cell_index == t - 1:
	print('YES')
else:
	print('NO')


ntStr = input()
n = int(ntStr.split()[0])
t = int(ntStr.split()[1])
aiLsStr = input()
alLs = aiLsStr.split()
a = [0] * n
for i in range(n - 1):
	a[i + 1] = int(alLs[i])
i = 1
while i < t:
	i = i + a[i]
if i == t:
	print('YES')
else:
	print('NO')


(a, b) = input().split()
n = int(a)
t = int(b)
values = input().split()
j = 1
while j < t:
	j += int(values[j - 1])
	final = j
if final == t:
	print('YES')
else:
	print('NO')


(N, T) = [int(i) for i in input().split()]
numbers = [int(i) for i in input().split()]
cell = 0
answer = False
while cell <= T and cell <= len(numbers):
	try:
		cell = numbers[cell - 1] + cell
		if cell == T:
			print('YES')
			answer = True
	except:
		break
if answer == False:
	print('NO')


import sys
import math
(n, t) = map(int, input().split())
a = [int(x) for x in input().split()]
pos = 1
i = 0
while t > pos:
	pos += a[i]
	i = pos - 1
	if pos == t:
		print('YES')
		sys.exit()
print('NO')


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
i = 0
l = 1
while True:
	l += a[i]
	i = l - 1
	if l == m:
		print('YES')
		break
	elif l > m:
		print('NO')
		break


(n, t) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
cur = 1
w = True
for i in range(len(a)):
	if cur > t:
		w = False
		break
	elif cur == t:
		break
	else:
		cur += a[cur - 1]
if w:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
portals = list((int(x) for x in input().split()))
current = 1
while current < n:
	current += portals[current - 1]
	if current == t:
		print('YES')
		exit()
print('NO')


import collections

class AdjacencyList:

	def __init__(self, undirected=False):
		self.undirected = undirected
		self.vertices = set([])
		self.adjacency = {}

	def add_vertex(self, label):
		self.vertices.add(label)

	def _add_edge(self, v, u):
		try:
			self.adjacency[v].add(u)
		except KeyError:
			self.adjacency[v] = {u}

	def add_edge(self, v, u):
		self._add_edge(v, u)
		if self.undirected:
			self._add_edge(u, v)

	def delete_edge(self, v, u):
		self.adjacency[v].remove(u)
		if self.undirected:
			self.adjacency[u].remove(v)

	def delete_vertex(self, v):
		self.adjacency.pop(v)
		for neighbors in self.adjacency.values():
			if v in neighbors:
				neighbors.remove(v)

	def is_vertex(self, v):
		return v in self.vertices

	def is_edge(self, v, u):
		return u in self.children(v)

	def children(self, v):
		return self.adjacency.get(v, set([]))

	def parents(self, v):
		return set([key for (key, value) in self.adjacency.items() if v in value])

	def out_degree(self, v):
		return len(self.children(v))

	def in_degree(self, v):
		return len(self.parents(v))
from sys import stdin

def read_lines(sep=' ', input_type=None):
	_lines = stdin.readlines()
	cast = input_type is not None
	lines = []
	for line in _lines:
		line = line[:-1].split(sep)
		if cast:
			line = [input_type(x) for x in line]
		lines.append(line)
	return lines

def dfs(G, v, t):
	visited = set([])
	hit = [False]

	def _dfs(vv):
		if vv == t:
			hit[0] = True
			return
		visited.add(vv)
		for uu in G.children(vv):
			if uu not in visited:
				_dfs(uu)
	_dfs(v)
	return hit[0]

def dfs(G, v, t):
	stack = [v]
	visited = set([])
	while stack:
		u = stack.pop()
		visited.add(u)
		if u == t:
			return True
		children = G.children(u)
		for w in children:
			if w not in visited:
				stack.append(w)
	return False

def main():
	lines = read_lines(input_type=int)
	(n, target) = lines[0]
	idx = lines[1]
	graph = AdjacencyList(undirected=False)
	vertices = list(range(1, n + 1))
	edges = [(v, v + idx[v - 1]) for v in vertices[:-1]]
	for v in vertices:
		graph.add_vertex(v)
	for e in edges:
		graph.add_edge(*e)
	if target == 1:
		print('YES')
	elif dfs(graph, 1, target):
		print('YES')
	else:
		print('NO')
main()


nt = input().split()
n = int(nt[0])
t = int(nt[1])
world = list(map(int, input().split()))
mp = 1
while mp != t and mp < n:
	mp += world[mp - 1]
if mp == t:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
Line = [int(i) for i in input().split()]
L = [1]
a = 1
while True:
	a += Line[a - 1]
	L.append(a)
	if a == n:
		break
if t in L:
	print('YES')
else:
	print('NO')


from sys import stdin
(n, t) = str(stdin.readline()).strip().replace('\n', '').split()
n = int(n)
t = int(t)
arr = stdin.readline().replace('\n', '').split()
cur = 1
while cur < t:
	a = int(arr[cur - 1])
	cur += a
if t == cur:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
l = list(map(int, input().split()))
current = 1
while current != t:
	current += l[current - 1]
	if current == t:
		print('YES')
		break
	elif current > t:
		print('NO')
		break
else:
	print('NO')


(n, t) = input().split()
n = int(n)
t = int(t)
li = [int(num) for num in input().split()]
l = len(li)
m = t - 1
i = 0
c = 0
while i <= l:
	if i == m:
		c = c + 1
	i = i + li[i]
	if i >= l:
		break
if i + li[-1] == t or c > 0:
	print('YES')
else:
	print('NO')


def solve(w, t):
	i = 0
	while i < len(w):
		i += w[i]
		if i == t:
			return 'YES'
	return 'NO'
t = int(input().split()[1]) - 1
w = list(map(int, input().split()))
print(solve(w, t))


import re
(n, t) = map(int, input().split())
ai = re.findall('\\d+\\s', input() + ' ')
pos = 1
run = True
while run:
	pos += int(ai[pos - 1])
	if pos == t:
		print('YES')
		run = False
	elif pos > t:
		print('NO')
		run = False


(n, t) = list(map(int, input().split()))
cell_portals = list(map(int, input().split()))
current_cell = 1
while current_cell < t:
	current_cell += cell_portals[current_cell - 1]
if current_cell == t:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
i = 0
flag = False
while i < n - 1:
	if arr[i] + 1 + i == k:
		print('Yes')
		flag = True
		break
	i = arr[i] + i
if flag == False:
	print('No')


import sys
from random import choice, randint
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def MI():
	return map(int, sys.stdin.readline().strip().split())

def LI():
	return list(map(int, sys.stdin.readline().strip().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines().strip()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().strip().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().strip().split()]

def LS():
	return sys.stdin.readline().strip().split()

def I():
	return int(sys.stdin.readline().strip())

def F():
	return float(sys.stdin.readline().strip())

def S():
	return sys.stdin.readline().strip()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))
inp = sys.stdin.readline
out = sys.stdout.write

def main():
	(n, t) = MI()
	a = LI()
	i = 0
	while i < n - 1:
		if i + 1 == t or i + a[i] + 1 == t:
			pf('YES')
			break
		i = i + a[i]
	else:
		pf('NO')
main()


from collections import deque
(n, t) = map(int, input().split())
A = list(map(int, input().split()))
G = {}
for i in range(1, n + 1):
	G[i] = []
for i in range(1, n):
	G[i].append(i + A[i - 1])
V = [0 for i in range(0, n + 1)]
V[1] = 1
Q = deque([1])
F = 'NO'
while Q:
	x = Q.pop()
	if x == t:
		F = 'YES'
		break
	else:
		for i in G[x]:
			if V[i] == 0:
				V[i] = 1
				Q.append(i)
print(F)


import sys
from collections import defaultdict
mod = 1000000007

def get_array():
	return list(map(int, sys.stdin.readline().split()))

def get_ints():
	return map(int, sys.stdin.readline().split())

def input():
	return sys.stdin.readline()

def print_array(a):
	print(' '.join(map(str, a)))

def main():
	(n, s) = get_ints()
	a = get_array()
	c = 1
	flag = True
	while flag:
		c += a[c - 1]
		if c == s:
			break
		if c == n:
			flag = False
	print('YES' if flag else 'NO')
main()


(n, t) = map(int, input().split())
l = list(map(int, input().split()))
current = 1
flag = False
while current <= t:
	if current == t:
		flag = True
		print('YES')
		break
	current += l[current - 1]
if flag == False:
	print('NO')


(length, x) = [int(i) for i in input().split()]
portals = [int(i) for i in input().split()]
location = 1
while location < x:
	location += portals[location - 1]
if location == x:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
arr = list(map(int, input().split()))
visit = [1]
i = 0
while True:
	try:
		visit.append(i + arr[i] + 1)
		i = i + arr[i]
	except:
		break
if t in visit:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
visited = [False] * n
visited[0] = False
u = 0
while u < n - 1:
	visited[u] = True
	u = u + a[u]
visited[u] = True
if visited[t - 1]:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
p = [int(x) for x in input().split()]
k = 0
q = []
while k < t - 1:
	k = k + p[k]
	q += [k + 1]
print(['NO', 'YES'][any((x == t for x in q))])


(m, n) = map(int, input().split())
portals = [int(i) for i in input().split()]
check = 1
for i in range(m - 1):
	check += portals[check - 1]
	if check == n:
		print('YES')
		break
	elif check > n:
		print('NO')
		break


(n, t) = map(int, input().split())
a = [int(x) for x in input().split()]
b = [0] * n
i = 0
while i <= n - 2:
	i += a[i]
	b[i] = 1
print(['YES', 'NO'][b[t - 1] == 0])


(n, k) = map(int, input().split())
b = input().split()
i = 1
count = 0
while i < n:
	if k == 1:
		print('yes')
		break
	i += int(b[i - 1])
	if i == k:
		print('yes')
		count = 1
		break
if count == 0:
	print('no')


(s, t) = input().split()
x = list(map(int, input().split())) + [0]
visited = [0] * (int(s) + 1)
i = 1
while True:
	if i == int(t):
		print('YES')
		break
	if visited[i] == 1:
		print('NO')
		break
	visited[i] = 1
	i += x[i - 1]


(n, t) = map(int, input().split())
A = [int(x) for x in input().split()]
a = 1
for i in range(n - 1):
	A[i] = A[i] + i + 1
for i in range(n):
	a = A[a - 1]
	if t == a:
		print('YES')
		break
	elif a > t:
		print('NO')
		break


(n, m) = map(int, input().split(' '))
l = list(map(int, input().split(' ')))
k = 1
while True:
	if k == m:
		print('YES')
		break
	elif k > m:
		print('NO')
		break
	k += l[k - 1]


nt = input()
espacio = nt.index(' ')
n = int(nt[:espacio])
t = int(nt[espacio + 1:])
ies = input()
i = ies.split(' ')
i = [int(x) for x in i]
llego = False
pos = 1
while llego == False and pos < t:
	if pos == t:
		llego = True
	if llego == False:
		pos += i[pos - 1]
	else:
		pass
	if pos == t:
		llego = True
if llego == True:
	print('YES')
else:
	print('NO')


(n, t) = (int(i) for i in input().split())
portals = [int(i) for i in input().split()]
home = 1
while True:
	if home == t:
		print('YES')
		break
	elif home > t:
		print('NO')
		break
	home += portals[home - 1]


mark = 0
(n, t) = map(int, input().split())
a = [0]
a += list(map(int, input().split()))
k = 1
mark = 'NO'
while True:
	if k == t:
		mark = 'YES'
		break
	if k == n:
		break
	k += a[k]
print(mark)


d = [int(x) for x in input().split(' ')]
t = [int(x) for x in input().split(' ')]
p = 1
cond = False
for x in range(d[0]):
	p += t[p - 1]
	if p > d[1]:
		break
	if p == d[1]:
		cond = True
		break
if cond:
	print('YES')
else:
	print('NO')


(n, t) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
t -= 1
cur = 0
while cur < t:
	cur += a[cur]
	if cur == t:
		print('YES')
		quit()
print('NO')


(n, t) = map(int, input().split())
arr = list(map(int, input().split()))
arr = [0] + arr
val = 1
while True:
	if val == t:
		resultado = 'YES'
		break
	elif val > t:
		resultado = 'NO'
		break
	else:
		val += arr[val]
print(resultado)


(n, t) = map(int, input().split())
p = list(map(int, input().split()))
d = [0] * n
d[0] = 1
now = 0
while True:
	if now >= n - 1:
		break
	d[now + p[now]] = 1
	now += p[now]
if d[t - 1] == 1:
	print('YES')
else:
	print('NO')


(n, index) = map(int, input().split())
a = list(map(int, input().split()))
next = 1
while next < index:
	next += a[next - 1]
print('YES' if next == index else 'NO')


inp = input()
inp = inp.split()
length = int(inp[0])
goal = int(inp[1])
portals = input()
cell = 1
portals = portals.split()
portals2 = []
passed = False
for i in portals:
	portals2.append(int(i))
i = 0
while i < len(portals2):
	cell += portals2[i]
	i += portals2[i]
	if cell == goal:
		passed = True
		break
	if cell > goal:
		break
if passed:
	print('YES')
else:
	print('NO')


(n, t) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
p = 1
d = []
while p < n:
	p += a[p - 1]
	d.append(p)
if t in d:
	print('YES')
else:
	print('NO')


(n, m) = [int(i) for i in input().split()]
arr = [int(i) for i in input().split()]
val = 1
if val == m:
	print('YES')
while 1:
	if arr[val - 1] is None:
		print('NO')
		break
	val = val + arr[val - 1]
	if val == m:
		print('YES')
		break
	elif val > m:
		print('NO')
		break


(n, m) = map(int, input().split(' '))
mas = list(map(int, input().split(' ')))
i = 0
while i < m:
	i += mas[i]
	if i == m - 1:
		print('YES')
		break
else:
	print('NO')


(n, go) = map(int, input().split())
l = [0] + [int(i) for i in input().split()]
from collections import *
vis = defaultdict(lambda : False)
c = 0
i = 1
vis[1] = True
while i <= n and c + 1 < n and (c + 1 <= go):
	c += l[c + 1]
	vis[c + 1] = True
	i += 1
if vis[go]:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
transport = list(map(int, input().split()))
d = {}
for (i, item) in enumerate(transport, 1):
	d[i] = i + item
current = 1
while True:
	if current in d:
		current = d[current]
		if current == t:
			print('YES')
			break
	else:
		print('NO')
		break


s = input()
a = s.split()
for i in range(len(a)):
	a[i] = int(a[i])
s = input()
b = s.split()
for i in range(len(b)):
	b[i] = int(b[i])
i = 1
while i < a[1]:
	i += b[i - 1]
if i == a[1]:
	print('YES')
else:
	print('NO')


def travel(p, t, pos):
	while pos < t:
		pos = port[pos - 1]
	if pos == t:
		print('YES')
	else:
		print('NO')
line1 = input().split()
n = int(line1[0])
t = int(line1[1])
line2 = input().split()
port = []
for i in range(n - 1):
	port += [i + 1 + int(line2[i])]
travel(port, t, 1)


(n, t) = map(int, input().split())
l = [int(x) for x in input().split()]
place = 1
judge = 0
i = 0
while not judge and i < n - 1:
	place = i + l[i] + 1
	if place == t:
		judge = 1
		break
	i = place - 1
if judge:
	print('YES')
else:
	print('NO')


def solve():
	(n, t) = map(int, input().split())
	arr = [int(x) for x in input().split()]
	t -= 1
	i = 0
	while i < n:
		if i == t:
			print('YES')
			return
		i += arr[i]
		if i > t or i > n:
			break
	print('NO')
	return
solve()


input_string = input().split(' ')
n = int(input_string[0])
t = int(input_string[1]) - 1
a = []
input_string = input().split(' ')
for i in range(n - 1):
	a.append(int(input_string[i]))
graph = []
for i in range(n):
	graph.append([])
for i in range(n - 1):
	graph[i].append(i + a[i])

def bfs(graph, s, search):
	if s == search:
		print('YES')
	else:
		bool_yes = True
		q = []
		visited = [False] * len(graph)
		q.append(s)
		visited[s] = True
		while len(q) > 0:
			u = q.pop()
			if u == search:
				bool_yes = False
				print('YES')
				break
			visited[u] = True
			for i in range(len(graph[u])):
				if not visited[graph[u][i]]:
					q.append(graph[u][i])
	if bool_yes:
		print('NO')
bfs(graph, 0, t)


(n, t) = [int(i) for i in input().split()]
mas = [int(i) for i in input().split()]
i = 1
check = False
while i <= n:
	if i == t:
		check = True
		break
	elif i != n:
		i += mas[i - 1]
	else:
		break
if check:
	print('YES')
else:
	print('NO')


a = input().split()
m = int(a[1])
k = 0
n = input().split()
for i in range(len(n) + 1):
	if k == m - 1:
		print('YES')
		break
	elif k > m - 1:
		print('NO')
		break
	else:
		k += int(n[k])


k = lambda : map(int, input().split())
t = list(k())[1]
(*l,) = k()
s = 0
while s < t - 1:
	s += l[s]
print('YNEOS'[s > t - 1::2])


(x, y) = [int(x) for x in input().split()]
li = [int(x) for x in input().split()]
num = 1
while num <= len(li):
	ne = li[num - 1]
	num += ne
	if num == y:
		print('YES')
		break
else:
	print('NO')


(n, t) = map(int, input().split())
lst = list((int(num) for num in input().split()))[:n]
lst1 = []
i = 1
while i <= n - 1:
	i = i + lst[i - 1]
	lst1.append(i)
if t in lst1:
	print('YES')
else:
	print('NO')


B = [int(m) for m in input().split()]
B[1] -= 1
A = [int(m) for m in input().split()]
i = 0
c = 0
while i < B[1]:
	if A[i] + i == B[1]:
		c += 1
		break
	i = A[i] + i
if c == 1:
	print('YES')
else:
	print('NO')


import sys
sys.setrecursionlimit(100000000)
s = input()
s = s.split()
n = int(s[0])
t = int(s[1])
t -= 1
s = input()
s = s.split()
d = {}
for i in range(len(s)):
	d[i] = int(s[i]) + i

def dfs(d, start=0, end=t):
	stack = [start]
	while 1:
		te = stack.pop()
		if te == end:
			return 1
		if te not in d:
			return 0
		stack.append(d[te])
ans = dfs(d)
if ans == 1:
	print('YES')
else:
	print('NO')


(n, t) = input().split()
t = int(t) - 1
t1 = input().split()
t2 = list(map(int, t1))
ok = False
now = 0
while now < len(t2):
	now = now + t2[now]
	if now == t:
		ok = True
		break
if ok:
	print('YES')
else:
	print('NO')


import sys
sys.setrecursionlimit(10 ** 6)
debug_mode = True if len(sys.argv) > 1 and sys.argv[1] == '-d' else False
if debug_mode:
	import os
	infile = open(os.path.abspath(__file__).replace('.py', '.in'))

	def input():
		return infile.readline()
from collections import deque

def main():
	(n, t) = list(map(int, input().strip().split()))
	A = list(map(int, input().strip().split()))
	G = {i: [] for i in range(1, n + 1)}
	for (i, a) in enumerate(A):
		G[i + 1].append(i + 1 + a)
	(Q, S) = (deque([1]), set())
	while Q:
		curr = Q.popleft()
		if curr in S:
			continue
		if curr == t:
			print('YES')
			return
		Q.extend(G[curr])
	print('NO')
main()
if debug_mode:
	infile.close()


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
m = 'NO'
i = 1
while i <= n:
	if i == t:
		m = 'YES'
		break
	if i == n:
		break
	i += a[i - 1]
print(m)


[n, k] = [int(x) for x in input().split()]
por = [int(x) for x in input().split()]
a = [1]
here = 1
while here < n:
	here += por[here - 1]
	a.append(here)
if k in a:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
lst = list(map(int, input().split()))
i = 0
while i <= n - 2:
	i = lst[i] + i
	if i + 1 == t:
		print('YES')
		break
	elif i + 1 > t:
		print('NO')
		break


__author__ = 'Rakshak.R.Hegde'

def mint():
	return map(int, input().split())
(n, t) = mint()
a = list(mint())
curr = 1
while curr < t:
	curr = curr + a[curr - 1]
print('YES' if curr == t else 'NO')


(n, t) = map(int, input().split())
a = [int(i) for i in input().split()]
path = {}
for i in range(len(a)):
	path[i + 1] = i + 1 + a[i]
position = 1
target = t
flag = False
while position <= target:
	position = path[position]
	if position == target:
		flag = True
		break
if flag:
	print('YES')
else:
	print('NO')


def main():
	(n, t) = map(int, input().split())
	lines = list(map(int, input().split()))
	current = 1
	res = 'NO'
	while current < t:
		current += lines[current - 1]
		if current == t:
			res = 'YES'
	print(res)
main()


(numCells, cellDesejada) = [int(i) for i in input().split()]
portais = [int(i) for i in input().split()]
posicao = 1
for i in range(numCells - 1):
	posicao += portais[posicao - 1]
	if posicao == cellDesejada:
		print('YES')
		break
	if posicao > cellDesejada:
		print('NO')
		break


(n, t) = input().split(' ')
n = int(n)
t = int(t)
a = input().split()
for i in range(len(a)):
	a[i] = int(a[i])
g = 1
while g != t:
	if g > t:
		print('NO')
		break
	elif g < t:
		g += a[g - 1]
if g == t:
	print('YES')


x = input()
(n, t) = (int(x.split()[0]), int(x.split()[1]))
y = input()
f = [int(i) for i in y.split()]
cell = 1
count = 1
while cell < t and count <= n:
	cell = cell + f[cell - 1]
	count += 1
if cell == t:
	print('YES')
else:
	print('NO')


(cells, go_index) = input().split(' ')
cells = int(cells)
go_index = int(go_index)
portal_connections = [int(p) for p in input().split(' ')]
current_local = 1
i = 0
while True:
	if current_local == go_index:
		print('YES')
		break
	if current_local == cells:
		print('NO')
		break
	current_local += portal_connections[i]
	i += portal_connections[i]


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list()
b.append(1)
while b[-1] - 1 < len(a):
	b.append(b[-1] + a[b[-1] - 1])
if k in b:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
l = list(map(int, input().split()))
a = l[0] + 1
b = int(a)
while a < t:
	a = l[b - 1] + b
	b = int(a)
print('YES' if a == t else 'NO')


def read_nums():
	return [int(x) for x in input().split()]

def main():
	(n, t) = read_nums()
	nums = read_nums()
	cur_place = 0
	for _ in range(n):
		if cur_place + 1 == t:
			print('YES')
			exit()
		elif cur_place + 1 == n:
			print('NO')
			exit()
		cur_place = cur_place + nums[cur_place]
	print('NO')
main()


lots = input().split()
tudo = input().split()
n = 0
destino = int(lots[1]) - 1
while n < destino:
	n += int(tudo[n])
if n == destino:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
portal = [int(x) for x in input().split()]
me = 1
while me < t:
	me += portal[me - 1]
if me == t:
	print('YES')
else:
	print('NO')


(n, t) = [int(i) for i in input().split()]
line = [int(i) for i in input().split()]
s = 1
visit = []
while s < n:
	visit.append(s)
	s += line[s - 1]
visit.append(s)
if t in visit:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
arr = list(map(int, input().split()))
graph = {i: set() for i in range(1, n + 1)}
for i in range(n - 1):
	graph[i + 1] = graph[i + 1].union(set([i + 1 + arr[i]]))
for i in range(1, n + 1):
	if i == 1:
		temp = next(iter(graph[1]))
	else:
		if temp == t:
			print('YES')
			break
		elif temp > t:
			print('NO')
			break
		temp = next(iter(graph[temp]))


from __future__ import division, print_function
import itertools, os, sys, threading
from collections import deque, Counter, OrderedDict, defaultdict
from math import ceil, floor, log, sqrt, factorial, pow, pi

def ii():
	return int(input())

def si():
	return str(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
graph = defaultdict(list)
visited = [0] * 1000000
col = [-1] * 1000000

def dfs(v, c):
	if visited[v]:
		if col[v] != c:
			print('-1')
			exit()
		return
	col[v] = c
	visited[v] = 1
	for i in graph[v]:
		dfs(i, c ^ 1)

def bfs(d, v):
	q = []
	q.append(v)
	visited[v] = 1
	while len(q) != 0:
		x = q[0]
		q.pop(0)
		for i in d[x]:
			if visited[i] != 1:
				visited[i] = 1
				q.append(i)
		print(x)

def make_graph():
	d = {}
	(v, e) = mi()
	for i in range(e):
		(x, y) = mi()
		if x not in d.keys():
			d[x] = [y]
		else:
			d[x].append(y)
		if y not in d.keys():
			d[y] = [x]
		else:
			d[y].append(x)
	return d

def gr2(n):
	d = {}
	for i in range(n):
		(x, y) = mi()
		if x not in d.keys():
			d[x] = [y]
		else:
			d[x].append(y)
	return d
(n, t) = mi()
l = li()
p = l[0]
i = 0
while p < t:
	p = p + l[i - 1]
	i = p
if i == t:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
transportation = {}
adds = list(map(int, input().split()))
for i in range(n - 1):
	transportation.update({i + 1: adds[i] + i + 1})
steps = [1]
while True:
	steps.append(transportation[steps[-1]])
	if steps[-1] >= t:
		break
if t in steps:
	print('YES')
else:
	print('NO')


(n, key) = map(int, input().split())
l = list(map(int, input().split()))
pos = 1
while pos <= n and pos < key:
	pos += l[pos - 1]
if pos == key:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().rstrip().split())
array = list(map(int, input().rstrip().split()))
import math
i = 0
while i <= n - 1:
	if i == t - 1:
		print('YES')
		break
	if i > t - 1:
		print('NO')
		break
	i = i + array[i]


p = lambda : map(int, input().split())
(N, T) = p()
a = (*p(),)
n = 1
while n < T:
	n += a[n - 1]
print('YNEOS'[n > T::2])


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
p = 1
lol = 0
for i in range(n):
	if p > k:
		break
	if p == k:
		lol = 1
		break
	p = l[p - 1] + p
if lol:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
p = [int(x) for x in input().split()]
(c, acc) = (0, [])
while c < len(p):
	c += p[c]
	acc.append(c + 1)
print(['NO', 'YES'][t in acc])


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
dest = [i + a[i] + 1 for i in range(n - 1)]
pos = 1
ans = 'NO'
while True:
	pos = dest[pos - 1]
	if pos == t:
		ans = 'YES'
		break
	elif pos > t:
		break
print(ans)


(n, p) = list(map(int, input().split()))
v = list(map(int, input().split()))
ind = 0
i = 0
while i + 1 != n:
	i = v[i] + i
	if i + 1 == p:
		ind = 1
		break
if ind == 0:
	print('NO')
else:
	print('YES')


(n, t) = map(int, input().split())
cells = [int(i) for i in input().split()]
cells.append(int(0))
(c, s, ans) = ([0 for i in range(n)], cells[0], 0)
while ans < n - 1:
	if ans + 1 == t:
		break
	(ans, s) = (ans + s, cells[ans + s])
if ans + 1 == t:
	print('Yes')
else:
	print('No')


(n, t) = map(int, input().split())
path = list(map(int, input().split()))
path.insert(0, 0)
idex = 1
while idex < t:
	idex += path[idex]
print('YES' if idex == t else 'NO')


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
a.insert(0, 0)
(i, num, res) = (1, 0, 'NO')
while True:
	num = i + a[i]
	if i > len(a) - 1 or num > t:
		break
	elif num == t:
		res = 'YES'
		break
	i = num
print(res)


(n, k) = map(int, input().split())
lis = list(map(int, input().split()))
p = [1]
i = 0
while i != n - 1:
	m = p[-1]
	p.append(m + lis[i])
	i = m + lis[i] - 1
if k in p:
	print('YES')
else:
	print('NO')


(n, t) = list(map(int, input().strip().split(' ')))
av = list(map(int, input().strip().split(' ')))
endp = []
for (i, val) in enumerate(av):
	endp.append(i + val + 1)
cell = 1
visited = set()
ans = ''
while 1:
	if cell == t:
		ans = 'YES'
		break
	if cell in visited or cell >= n:
		ans = 'NO'
		break
	else:
		visited.add(cell)
		cell = endp[cell - 1]
print(ans)


(n, t) = [int(i) for i in input().split()]
L = [int(i) for i in input().split()]
r = 'NO'
i = 1
while i <= t:
	if i == t:
		r = 'YES'
		break
	else:
		i = i + L[i - 1]
print(r)


(n, t) = [int(k) for k in input().split()]
a = [int(k) for k in input().split()]
if len(a) != n:
	a.append(1)
x = 1
while x < t:
	x += a[x - 1]
if x == t:
	print('YES')
else:
	print('NO')


(n, x) = map(int, input().split())
s = [int(i) for i in input().split()]
i = 0
while i < x - 1:
	i += s[i]
if i == x - 1:
	print('YES')
else:
	print('NO')


(n, t) = [int(p) for p in input().split()]
a = [int(j) for j in input().split()]
i = 1
tm = 0
while i <= n:
	if i == t:
		print('YES')
		break
	tm = i + a[i - 1]
	if tm > t:
		print('NO')
		break
	i = tm
if i > n:
	print('NO')


(a, b) = map(int, input().split())
l = list(map(int, input().split()))
l.reverse()
l.append(0)
l.reverse()
z = 1
while z < b:
	z += l[z]
if z == b:
	print('YES')
else:
	print('NO')


import sys
(n, x) = map(int, input().split())
x -= 1
a = list(map(int, input().split()))
y = 0
while y < x:
	y += a[y]
	if y == x:
		print('YES')
		sys.exit()
print('NO')


(n, t) = [int(s) for s in input().split()]
a = [int(s) for s in input().split()]
a.insert(0, 0)
p = 1
while p < n:
	p += a[p]
	if p == t:
		print('YES')
		break
else:
	print('NO')


import sys

def main():
	(n, t) = map(int, input().split())
	tab = list(map(int, sys.stdin.readline().split()))
	p = 0
	for i in range(0, n - 1):
		if i == p:
			p += tab[i]
			if p >= t - 1:
				break
	if p == t - 1:
		print('YES')
	else:
		print('NO')
main()


(n, m) = map(int, input().split(' '))
m = m - 1
graph = []
for i in range(n - 1):
	graph.append([])
nodes = input().split(' ')
for i in range(n - 1):
	graph[i].append(int(nodes[i]) + i)
stack = []
stack.append(0)
while stack:
	node = stack.pop()
	if node == m:
		print('YES')
		break
	if node < n - 1:
		stack.append(graph[node][0])
else:
	print('NO')


def hop(array, t):
	i = 1
	while i <= t:
		if i == t:
			return 'YES'
		i += int(array[i - 1])
	return 'NO'

def main():
	line = input().rstrip().split()
	n = int(line[0])
	t = int(line[1])
	array = list(map(int, input().rstrip().split()))
	print(hop(array, t))
main()


(N, T) = input().split(' ')
T = int(T)
N = int(N)
a = [int(x) for x in input().split(' ')]

def det(T, N, a):
	j = 1
	i = 0
	while j < T:
		j = j + a[j - 1]
	if j == T:
		return 'Yes'
	else:
		return 'No'
print(det(T, N, a))


import sys
inp = sys.stdin.readline().split()
m = int(inp[0])
n = int(inp[1])
imp = sys.stdin.readline().split()
T = [int(imp[x]) for x in range(m - 1)]
L = [0 for x in range(m)]
i = 1
L[0] = 1
while i <= m - 1:
	i = i + T[i - 1]
	L[i - 1] = 1
if L[n - 1] == 1:
	print('YES')
else:
	print('NO')


def seperateints(x):
	k = ''
	l = []
	for i in x:
		if i == ' ':
			l.append(int(k))
			k = ''
			continue
		k = k + i
	l.append(int(k))
	return l

def luckynum(x):
	for i in x:
		if i != '4' and i != '7':
			return False
	return True
n = seperateints(input())
l = seperateints(input())
i = 1
s = 0
while i <= n[1]:
	if i == n[1]:
		s += 1
		break
	i = i + l[i - 1]
if s == 0:
	print('NO')
else:
	print('YES')


(n, t) = [int(x) for x in input().split()]
nums = [int(x) for x in input().split()]
c = 1
while c < t:
	c += nums[c - 1]
if c == t:
	print('YES')
else:
	print('NO')


(a, b) = map(int, input().split())
s = list(map(int, input().split()))
d = 1
while d < b:
	d += s[d - 1]
if d == b:
	print('YES')
else:
	print('NO')


(n, t) = [int(x) for x in input().split()]
s = [int(x) for x in input().split()]
m = [1]
cell = 1
while cell <= n - 1:
	cell += s[cell - 1]
	m.append(cell)
	if cell == t:
		print('YES')
if t not in m:
	print('NO')


import sys

def main():
	(cells, goTo) = [int(x) for x in sys.stdin.readline().strip().split()]
	portal = [int(x) for x in sys.stdin.readline().strip().split()]
	ind = 0
	while ind < cells - 1 and ind != goTo - 1:
		ind += portal[ind]
	if ind == goTo - 1:
		print('Yes')
	else:
		print('No')
main()


from collections import defaultdict, deque

def bfs(graph, target):
	(visited, queue) = (set(), deque([1]))
	while queue:
		vertex = queue.pop()
		if vertex not in visited:
			visited.add(vertex)
			if vertex == target:
				return True
			elif vertex > target:
				return False
			queue.extendleft(set(graph[vertex]) - visited)
	return False
(n, t) = map(int, input().split())
a = list(map(int, input().split()))
s = defaultdict(set)
for i in range(1, n):
	s[i].add(i + a[i - 1])
print('YNEOS'[not bfs(s, t)::2])


def solve(n, t, a):
	output = 'NO'
	i = 1
	while i < n:
		i += a[i - 1]
		if i < t:
			continue
		if i == t:
			output = 'YES'
		break
	return output
(n, t) = map(int, input().split())
a = list(map(int, input().split()))
print(solve(n, t, a))


cell = list(map(int, input().split()))
portal = list(map(int, input().split()))
answer = []
visit = 1
for i in range(cell[0] - 1):
	visit = visit + portal[visit - 1]
	if visit == cell[1]:
		print('YES')
		break
	if visit > cell[1]:
		print('NO')
		break


(n, t) = [int(x) for x in input('').split()]
portals = [int(x) for x in input('').split()]
possibles = [1]
poss = 1
while poss < n:
	poss += portals[poss - 1]
	possibles.append(poss)
if t in possibles:
	print('YES')
else:
	print('NO')


(n, y) = map(int, input().split())
l = [int(n) for n in input().split()]
pos = 0
z = y - 1
while pos <= z:
	if pos < z:
		pos = pos + l[pos]
	elif pos == z:
		print('YES')
		break
	elif pos > z:
		print('NO')
		break
	else:
		print('error')
if pos > z:
	print('NO')


(n, t) = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
c = 1
while True:
	if c == t:
		ans = True
		break
	elif c == n:
		ans = False
		break
	else:
		c += A[c - 1]
print('YES' if ans else 'NO')


(n, t) = input().split()
(n, t) = (int(n), int(t))
word = list(map(int, input().split()))
x = 1
while x < t:
	x += word[x - 1]
print('YES' if x == t else 'NO')


(n, t) = map(int, input().split())
a = [int(i) for i in input().split()]
f = [0 for i in range(n)]
pos = 0
while pos < n:
	f[pos] = 1
	if pos >= len(a):
		break
	else:
		pos += a[pos]
if f[t - 1] == 1:
	print('YES')
else:
	print('NO')


(a, b) = map(int, input().split())
c = input().split()
d = []
for i in range(len(c)):
	c[i] = int(c[i])
i = 0
while i < len(c) + 1:
	j = 1 + i + c[i]
	i = j - 1
	if j == b:
		print('YES')
		break
	if j > len(c):
		break
if j != b:
	print('NO')


(n, t) = map(int, input().split(' '))
aline = input().split(' ')
a = [int(i) for i in aline]
space = 1
transport = [space]
j = 0
yes = False
while space <= t:
	space += a[j]
	if t == space:
		print('YES')
		yes = True
		break
	transport.append(space)
	j = space - 1
if not yes:
	print('NO')


(n, t) = [int(x) for x in input().split()]
cell = [int(x) for x in input().split()]
cell.insert(0, 0)
visited = set()
current = 1
possible = False
while current not in visited:
	if current == t:
		possible = True
		break
	visited.add(current)
	if current < n:
		current += cell[current]
if possible:
	print('YES')
else:
	print('NO')


k = list(map(int, input().rstrip().split()))
n = k[0]
t = k[1]
a = k = list(map(int, input().rstrip().split()))
index = 0
i = 0
flag = 0
while index < n - 1:
	index += a[i]
	i += a[i]
	if index == t - 1:
		print('YES')
		flag = 1
		break
if flag == 0:
	print('NO')


entrada = input().split()
final = int(entrada[1])
celulas = input().split()
posicao = 1
printou = 0
while posicao <= final:
	if posicao == final:
		print('YES')
		printou = 1
		break
	else:
		posicao += int(celulas[posicao - 1])
if not printou:
	print('NO')


(n, t) = [int(x) for x in input().split()]
position = [1]
num = 1
leap = list(map(int, input().split()))
while num < n:
	s = leap[num - 1]
	num += int(s)
	position.append(num)
if t in position:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
b = [1]
s = 1
while s < n:
	try:
		s = s + a[s - 1]
		b.append(s)
	except IndexError:
		break
print('NYOE S'[t in b::2])


import sys
from sys import stdin, stdout
import bisect
import math
import heapq

def modinv(n, p):
	return pow(n, p - 2, p)

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())
import math

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l

def main():
	(n, m) = cin()
	a = ain()
	i = 0
	ans = 'NO'
	if m == i + 1:
		ans = 'YES'
	while i < n - 1:
		i += a[i]
		if m == i + 1:
			ans = 'YES'
	print(ans)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def readnumbers(zero=0):
	conv = ord if py2 else lambda x: x
	A = []
	numb = zero
	sign = 1
	i = 0
	s = sys.stdin.buffer.read()
	try:
		while True:
			if s[i] >= b'0'[0]:
				numb = 10 * numb + conv(s[i]) - 48
			elif s[i] == b'-'[0]:
				sign = -1
			elif s[i] != b'\r'[0]:
				A.append(sign * numb)
				numb = zero
				sign = 1
			i += 1
	except:
		pass
	if s and s[-1] >= b'0'[0]:
		A.append(sign * numb)
	return A
main()


(a, b) = map(int, input().split(' '))
x = list(map(int, input().split(' ')))
curr = 1
while curr <= b:
	curr += x[curr - 1]
	if curr == b:
		print('YES')
		quit()
if curr == b:
	print('YES')
else:
	print('NO')


def readgraph(s):
	graph = {}
	for i in range(1, len(s) + 1):
		graph[i] = i + s[i - 1]
	return graph

def search(s, elem):
	i = 1
	err = False
	while i != elem and (not err):
		i = s[i]
		err = i > elem
	if err:
		print('NO')
	else:
		print('YES')
m = [int(i) for i in input().split()][1]
d = readgraph([int(i) for i in input().split()])
search(d, m)


(n, t) = map(int, input().split())
list = list(map(int, input().split()))
i = 0
while i < n - 1:
	i += list[i]
	if i == t - 1:
		print('YES')
		exit()
	else:
		pass
print('NO')


(n, t) = map(int, input().split())
li = [int(x) for x in input().split()]
lili = [1]
cd = 1
while cd < n:
	cd += li[cd - 1]
	lili.append(cd)
if t in lili:
	print('YES')
else:
	print('NO')


(n, a) = [int(j) for j in input().split()]
zaina = 1
dierhang = [int(k) for k in input().split()]
if a == 1:
	print('YES')
	exit()
for i in range(1, len(dierhang) + 1):
	if zaina == i:
		zaina = zaina + dierhang[i - 1]
	if zaina == a:
		print('YES')
		exit()
print('NO')


isDebug = False
(n, t) = str(input()).split()
s = str(input()).split()
result = False
idx = 0
target = int(t) - 1
n = int(n)
while True:
	if isDebug:
		print(f'idx={idx}, target={target}')
	if idx == target:
		result = True
		break
	elif idx > target:
		break
	idx = idx + int(s[idx])
print(f"{('YES' if result else 'NO')}")


(amount, target) = [int(x) for x in input().split()]
portals = [int(x) for x in input().split()]
cell = 1
while cell != target:
	cell += portals[cell - 1]
	if cell == target:
		print('YES')
		break
	if cell > target:
		print('NO')
		break


t = int(input().split()[1])
ai = [0] + list(map(int, input().split()))
i = 1
while i < t:
	i = i + ai[i]
print('YES' if i == t else 'NO')


(n, t) = [int(i) for i in input().split()]
m = input().split()
s = 1
for j in range(t):
	s += int(m[s - 1])
	if s == t:
		print('YES')
		break
	elif s > t:
		print('NO')
		break


(n, t) = map(int, input().split(' '))
l = list(map(int, input().split(' ')))
m = [l[i] + i + 1 for i in range(n - 1)]
x = 0
while x < t - 1:
	x += l[x]
if x == t - 1:
	print('YES')
else:
	print('NO')


from collections import defaultdict

def main():
	(cells, target) = map(int, input().split())
	a = [int(i) for i in input().split()]
	graph = defaultdict(int)
	visited = defaultdict(int)
	stack = [1]
	found = False
	while stack:
		node = stack.pop()
		if node == target:
			print('YES')
			found = True
			break
		(x, y) = (a[node - 1] + node, a[node - 1] - node)
		if x <= target and (not visited[x]):
			stack.append(x)
			visited[x] += 1
		if y >= 1 and (not visited[y]):
			stack.append(y)
			visited[y] += 1
	if not found:
		print('NO')
main()


n = input().split()
k = int(n[1])
m = int(n[0])
a = list(map(int, input().split()))
(c, x) = (0, 0)
for i in range(0, m):
	if c + 1 > k:
		break
	elif c + 1 == k:
		x = 1
		break
	c = a[c] + c
print('YES' if x == 1 else 'NO')


import sys
(n, t) = [int(i) for i in input().split()]
portals = [int(i) for i in input().split()]
casa = 1
while casa <= t:
	if casa == t:
		print('YES')
		sys.exit(0)
	casa += portals[casa - 1]
print('NO')


(n, t) = input().split()
(n, t) = (int(n), int(t))
a = input().split()
for i in range(n - 1):
	a[i] = int(a[i])
i = 1
while i != t and i < n:
	i += a[i - 1]
if i == t:
	print('YES')
else:
	print('NO')


(k, n) = map(int, input().split())
ls = list(map(int, input().split()))
index = 1
while index < n:
	index = index + ls[index - 1]
if index == n:
	print('YES')
else:
	print('NO')


import sys
Inpt_1 = list(map(int, input().split()))
Inpt_2 = list(map(int, input().split()))
I = 0
for Count in range(Inpt_1[0]):
	I += Inpt_2[I]
	if I > Inpt_1[1] - 1:
		print('NO')
		sys.exit()
	if I == Inpt_1[1] - 1:
		print('YES')
		sys.exit()
	if not Inpt_2[I]:
		print('NO')


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
pos = 1
found = False
seen = {pos}
while pos != n:
	pos += a[pos - 1]
	if pos in seen:
		break
	seen.add(pos)
	if pos == t:
		found = True
		break
if found:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
arr = [[i, 0] for i in range(1, n + 1)]
step = list(map(int, input().split()))
for i in range(n - 1):
	s = step[i]
	arr[i][1] = arr[i][0] + s
id = 1
while arr[id - 1][1] != 0 and arr[id - 1][1] != t:
	id = arr[id - 1][1]
pos = arr[id - 1][1]
if pos == t:
	print('YES')
else:
	print('NO')


(n, t) = [int(x) for x in input().split()]
cell = [1]
L = [int(x) for x in input().split()]
L = L + [0]
p = 1
while p < n:
	p = p + L[p - 1]
	cell.append(p)
if t in cell:
	print('YES')
else:
	print('NO')


(n, t) = list(map(int, input().split()))
a = list(map(int, input().split()))
already_visited = [1]
for i in range(n - 1):
	if i + 1 + a[i] == t and i + 1 in already_visited:
		print('YES')
		exit()
	if i + 1 in already_visited:
		already_visited.append(i + 1 + a[i])
print('NO')


(n, t) = input().split(' ')
(n, t) = (int(n), int(t))
s = list(input().split(' '))
k = int(0)
while k < t - 1:
	k = k + int(s[k])
if k == t - 1:
	print('YES')
else:
	print('NO')


from __future__ import division, print_function
import itertools, os, sys
from collections import deque, Counter, OrderedDict, defaultdict
from atexit import register
from io import BytesIO, StringIO
if sys.version_info[0] < 3:
	range = xrange
	filter = itertools.ifilter
	map = itertools.imap
	zip = itertools.izip
	sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
	sys.stdout = BytesIO()
	register(lambda : os.write(1, sys.stdout.getvalue()))
else:
	sys.stdin = StringIO(os.read(0, os.fstat(0).st_size).decode())
	sys.stdout = StringIO()
	register(lambda : os.write(1, sys.stdout.getvalue().encode()))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def ii():
	return int(input())

def si():
	return str(input())

def mi():
	return map(int, input().strip().split(' '))

def li():
	return list(mi())
(n, t) = mi()
l = li()
(i, f) = (1, 0)
while i < n:
	if i == t:
		print('YES')
		exit()
	else:
		i = l[i - 1] + i
if i == t:
	print('YES')
	exit()
print('NO')


a = input().split()
b = input().split()
i = 0
while i != int(a[1]) - 1 and i < int(a[0]) - 1:
	i += int(b[i])
if i == int(a[1]) - 1:
	print('YES')
else:
	print('NO')


def main():
	(n, t) = tuple(map(int, input().rstrip().split()))
	A = tuple(map(int, input().rstrip().split()))
	D = {i: i + j for (i, j) in enumerate(A, start=1)}
	cur = 1
	while cur < t:
		cur = D[cur]
	flg = cur == t
	print('YES' if flg else 'NO')
main()


def transport():
	(cells, target) = map(int, input().split())
	transport = list(map(int, input().split()))
	position = 1
	while position < cells:
		if position == target:
			print('YES')
			return
		position += transport[position - 1]
	if position == target:
		print('YES')
		return
	print('NO')
	return
transport()


nt = input('').split(' ')
cells = input('').split(' ')
cells = [int(i) for i in cells]
person = 1
success = False
i = 0
while i < int(nt[0]):
	if person == int(nt[1]):
		success = True
		break
	elif person > int(nt[1]):
		break
	person += cells[i]
	i = person - 1
if success:
	print('YES')
else:
	print('NO')


from collections import defaultdict
d = defaultdict(list)
(n, dest) = map(int, input().split())
dest = dest - 1
l = [int(i) for i in input().split()]
for i in range(n - 1):
	d[i].append(i + l[i])

def isreachable(dest):
	q = [0]
	visited = [False] * n
	visited[0] = True
	while q:
		temp = q.pop(0)
		for i in d[temp]:
			if not visited[i]:
				q.append(i)
				visited[i] = True
	return visited[dest]
print('YES' if isreachable(dest) else 'NO')


def main():
	(n, t) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	curPos = 1
	while curPos <= n - 1:
		if curPos + a[curPos - 1] == t:
			print('YES')
			return
		elif curPos + a[curPos - 1] > t:
			print('NO')
			return
		else:
			curPos = curPos + a[curPos - 1]
	print('NO')
main()


(n, t) = map(int, input().split())
portals = list(map(int, input().split()))
j = 1
flag = False
while j <= t:
	j = portals[j - 1] + j
	if j == t:
		flag = True
		break
if flag:
	print('YES')
else:
	print('NO')


l = list(map(int, input().split()))
T = list(map(int, input().split()))
n = l[0]
d = l[1]
i = 1
ok = 0
while i != n and ok == 0:
	if i == d:
		print('YES')
		ok = 1
	i = i + T[i - 1]
if ok == 0:
	if n == d:
		print('YES')
	else:
		print('NO')


(n, t) = map(int, input().split())
arr = list(map(int, input().split()))
currCell = 1
while currCell < n:
	if currCell == t:
		break
	currCell = arr[currCell - 1] + currCell
if currCell == t:
	print('YES')
else:
	print('NO')


(n, index) = map(int, input().split())
value_list = list(map(int, input().split()))
solved = False
pointer = 0
for i in range(len(value_list) + 1):
	if pointer == index - 1:
		print('YES')
		solved = True
		break
	if pointer < len(value_list):
		pointer += value_list[pointer]
if not solved:
	print('NO')


(n, t) = [int(x) for x in input().split()]
cells = list(map(int, input().split()))
pos = 1
dest = t
while pos < dest:
	ai = cells[pos - 1]
	pos = ai + pos
	if pos == dest:
		print('YES')
		exit()
print('NO')


(n, t) = map(int, input().split())
portals = list(map(int, input().split()))
i = 0
used = [False] * n
while i < t - 1:
	i = i + portals[i]
	used[i] = True
if used[t - 1]:
	print('YES')
else:
	print('NO')


(n, k) = [int(i) for i in input().split(' ')]
l = [int(i) for i in input().split(' ')]
m = [1]
cur = 1
while cur < n:
	cur += l[cur - 1]
	m.append(cur)
print('YES') if k in m else print('NO')


_inputs = ['8 5', '1 2 1 2 1 1 1']
_inputs = [input() for _ in range(2)]
(n, t) = [int(x) for x in _inputs[0].split()]
portals = [int(x) for x in _inputs[1].split()]
pos = 0
target = t - 1
while True:
	if pos > target:
		print('NO')
		exit()
	elif pos == target:
		print('YES')
		exit()
	pos += portals[pos]


num1 = list(map(int, input().strip().split()))
num2 = list(map(int, input().strip().split()))
res = 1
for i in num2:
	res += num2[res - 1]
	if res < num1[1]:
		continue
	elif res == num1[1]:
		print('YES')
		break
	else:
		print('NO')
		break


def main():
	(n, t) = [int(c) for c in input().split()]
	portals = {i + 1: int(c) for (i, c) in enumerate(input().split())}
	pos = 1
	while pos <= n:
		if pos == t:
			print('YES')
			return
		if pos not in portals:
			print('NO')
			return
		pos = pos + portals[pos]
main()


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
i = 0
o = 0
while i <= n:
	sum = i + 1 + arr[i]
	if sum == m:
		print('YES')
		o = 9
		break
	elif sum > m:
		break
	i = sum - 1
if o != 9:
	print('NO')


(a, b) = input().split()
(a, b) = (int(a), int(b))
s = input()
lst = s.split()
for i in range(len(lst)):
	lst[i] = int(lst[i])
s = 0
p = 1
for i in range(len(lst)):
	while p <= a - 1:
		p = lst[p - 1] + p
		if p == b:
			print('YES')
			s = s + 1
			break
	if s >= 1:
		break
if s == 0:
	print('NO')


mod = 10 ** 9 + 7
(z, zz) = (input, lambda : list(map(int, z().split())))
from string import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0:
			return 0
	return 1
(n, k) = zz()
l = zz()
i = 1
while i < k:
	i += l[i - 1]
print('YES' if i == k else 'NO')


def main():
	(count, end) = list(map(int, input().split()))
	levels = list(map(int, input().split()))
	levels.append(0)
	arr = []
	current_index = 0
	while 1:
		if current_index == end - 1:
			print('YES')
			break
		elif current_index == current_index + levels[current_index]:
			print('NO')
			break
		else:
			current_index = current_index + levels[current_index]
main()


(total, target) = map(int, input().split())
portals = [int(a) for a in input().split()]
cell = 1
while True:
	if cell > target:
		print('NO')
		break
	cell += portals[cell - 1]
	if cell == target:
		print('YES')
		break


dc = dict()

def cd(v):
	for (x, t) in enumerate(v):
		x += 1
		dc[x] = x + t

def tr(v, ds):
	hw = set()
	cd(v)
	x = 1
	while x not in hw:
		if x == ds:
			return 'yes'
		hw.add(x)
		x = dc.get(x, 1)
	return 'no'
(n, t) = [int(x) for x in input().split()]
v = [int(x) for x in input().split()]
print(tr(v, t).upper())


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
i = 0
t = True
while t:
	if i + a[i] > n - 1:
		print('NO')
		t = False
	elif i + a[i] == n - 1:
		if m - 1 == n - 1:
			print('YES')
			t = False
		else:
			print('NO')
			t = False
	elif i + a[i] == m - 1:
		print('YES')
		t = False
	else:
		i += a[i]


(n, t) = (int(i) for i in input().split())
l = [int(i) for i in input().split()]
i = 0
c = 0
while i < n - 1:
	i += l[i]
	if i + 1 == t:
		print('YES')
		c = 1
		break
if c == 0:
	print('NO')


(cells, target) = map(int, input().split())
portals = [int(i) for i in input().split()]
cell = 1
while cell < target:
	cell += portals[cell - 1]
print('YES' if cell == target else 'NO')


(n, t) = map(int, input().split())
nums = list(map(int, input().split()))
graph = {}
source = 1
for num in nums:
	if source >= t:
		break
	graph[source] = num + source
	source += 1
node = 1
while True:
	if node == t:
		print('YES')
		exit()
	if node in graph:
		node = graph[node]
	else:
		print('NO')
		exit()


(n, t) = map(int, input().split())
portals = list(map(int, input().split()))
visitable = [1]
current_standing = 1
while True:
	current_standing += portals[current_standing - 1]
	if current_standing == t:
		print('YES')
		break
	elif current_standing > t:
		print('NO')
		break


(n, t) = [int(x) for x in input().split()]
portal = [int(x) for x in input().split()]
t -= 1
portal.append(-1)
indx = 0
flag = False
while True:
	if t < indx or indx == -1:
		break
	if indx == t:
		flag = True
		break
	indx += portal[indx]
if flag:
	print('YES')
else:
	print('NO')


from sys import stdin

def main():
	(n, t) = stdin_get_ints_list_from_line()
	a = stdin_get_ints_list_from_line()
	i = 1
	while i <= n:
		if i == t:
			return 'YES'
		if i >= n:
			break
		i += a[i - 1]
	return 'NO'

def stdin_get_ints_list_from_line():
	return list((int(x) for x in stdin.readline().strip().split(' ')))
print(main())


x = lambda : map(int, input().split())
(n, t) = x()
(a, i) = (list(x()), 1)
while i < t:
	i += a[i - 1]
print('YES' if i == t else 'NO')


(n, t) = map(int, input().split(' '))
A = list(map(int, input().split(' ')))
j = 1
i = 0
while j < n and j != t:
	j = j + A[j - 1]
if j == t:
	print('YES')
else:
	print('NO')


nt = list(map(int, input().split()))
a = list(map(int, input().split()))

def sol(nt, a):
	s = 0
	for i in range(0, len(a)):
		s += a[s]
		if s == len(a) and s != nt[1] - 1:
			break
		elif s == nt[1] - 1:
			return 'YES'
	return 'NO'
print(sol(nt, a))


(n, t) = map(int, input().split())
ints = list(map(int, input().split()))
aux = 0
while aux < t - 1:
	aux += ints[aux]
if aux == t - 1:
	print('YES')
else:
	print('NO')


import sys
import math
input = sys.stdin.readline

def inp():
	return int(input())

def inara():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
(n, m) = invr()
ara = inara()
m -= 1
now = 0
while now < m and now < n:
	now += ara[now]
if now == m:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
cells = list(map(int, input().split()))
caminhos = {}
for i in range(1, n):
	caminhos[i] = cells[i - 1] + i
ans = 1
valid = False
while True:
	if ans == t or caminhos[ans] == t:
		valid = True
		break
	if caminhos[ans] not in caminhos.keys():
		break
	ans = caminhos[ans]
print('YES') if valid else print('NO')


(n, k) = list(map(int, input().split()))
num = list(map(int, input().split()))
i = 0
s = 0
while s < k:
	s += num[i]
	i += num[i]
	if s == k - 1:
		break
if s == k - 1:
	print('YES')
else:
	print('NO')


(n, m) = input().split(' ')
n = int(n)
m = int(m)
seq = [1]
a = input()
line = a.split(' ')
c = 1
while c != n:
	c += int(line[c - 1])
	seq.append(c)
if m in seq:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
nums = list(map(int, input().split()))
nums = [0] + nums
cur = 1
while cur < min(n, t):
	cur += nums[cur]
print('YES' if cur == t else 'NO')


(n, k) = input().split()
ls = list(map(int, input().split()))
c = 1
pos = 1
i = 1
while int(k) > c:
	c = ls[i - 1] + i
	if c == int(k):
		print('YES')
		break
	if c > int(k):
		print('NO')
		break
	i = c


(n, t) = map(int, input().split())
l = 1
s = [1]
tran = input().split()
for i in range(n - 1):
	tran[i] = int(tran[i])
while l < n:
	l += tran[l - 1]
	s.append(l)
if t in s:
	print('YES')
else:
	print('NO')


from collections import defaultdict
(n, dest) = map(int, input().split())
values = list(map(int, input().split()))
graph = defaultdict(list)
for i in range(1, n):
	graph[i].append(values[i - 1] + i)
stack = [1]
Found = False
while stack:
	ele = stack.pop()
	if ele == dest:
		Found = True
		break
	for i in graph[ele]:
		if i in range(1, n + 1):
			stack.append(i)
if Found:
	print('YES')
else:
	print('NO')


import sys
sys.setrecursionlimit(10000)
input = sys.stdin.readline
(n, t) = map(int, input().rstrip().split())
a = [-1] + list(map(int, input().rstrip().split()))
for i in range(n):
	a[i] += i
stack = [t]
while stack:
	num = stack.pop(-1)
	if num == 1:
		print('YES')
		exit(0)
	for i in range(n):
		if a[i] == num:
			stack.append(i)
print('NO')


(n, t) = map(int, input().split())
s = list(map(int, input().split()))
tile = 1
for i in s:
	while tile <= t:
		tile += s[tile - 1]
		if tile == t:
			print('YES')
			exit()
	else:
		print('NO')
		exit()


(qtd, objetivo) = list(map(int, input().split()))
portais = list(map(int, input().split()))
x = 1
while x < objetivo:
	x += portais[x - 1]
if x == objetivo:
	print('YES')
else:
	print('NO')


class CodeforcesTask500ASolution:

	def __init__(self):
		self.result = ''
		self.target = 0
		self.connections = []

	def read_input(self):
		self.target = int(input().split(' ')[1])
		self.connections = [int(x) for x in input().split(' ')]

	def process_task(self):
		targets = [x + self.connections[x] + 1 for x in range(len(self.connections))]
		if self.target not in targets:
			self.result = 'NO'
		else:
			position = 1
			while position < self.target:
				position = targets[position - 1]
			if position == self.target:
				self.result = 'YES'
			else:
				self.result = 'NO'

	def get_result(self):
		return self.result
Solution = CodeforcesTask500ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


(n, t) = map(int, input().split())
l = list(map(int, input().split()))
p = 1
while p < t:
	p += l[p - 1]
print(['NO', 'YES'][p == t])


str = input().split()
(n, t) = (int(str[0]), int(str[1]))
a = [int(x) for x in input().split()]
a.append(1)
now = 0
while now < n:
	if now == t - 1:
		print('YES')
		break
	now += a[now]
else:
	print('NO')


(n, k) = map(int, input().split(' '))
arr = [int(i) for i in input().split(' ')]
res = 1
while True:
	res += arr[res - 1]
	if res == k:
		print('YES')
		exit()
	if res > k:
		print('NO')
		exit()


l = list(map(int, input().split()))
a = list(map(int, input().split()))
visit = []
visit.append(1)
i = 0
while i < len(a):
	visit.append(i + a[i] + 1)
	i = i + a[i]
print('YES' if l[1] in visit else 'NO')


h = [int(i) for i in input().split()]
n = h[0]
t = h[1]
a = [int(i) for i in input().split()]
k = 0
while k < t - 1:
	a1 = a[k] + k
	k = a1
if k == t - 1:
	print('YES')
else:
	print('NO')


(N, T) = map(int, input().split())
A = list(map(int, input().split()))
now = 0
while True:
	now += A[now]
	if now == T - 1:
		print('YES')
		break
	if now > T - 1:
		print('NO')
		break


(n, t) = map(int, input().split())
l = list(map(int, input().split()))
s = 0
while s < t - 1:
	s += l[s]
if s < t:
	print('YES')
else:
	print('NO')


I = lambda : map(int, input().split())
(n, t) = I()
a = (*I(),)
x = 0
while x < t - 1:
	x += a[x]
print('YNEOS'[x >= t::2])


def newYear(n, t, cells):
	if t == 1:
		print('YES')
		return
	i = 1
	while i < len(cells) + 2:
		portal = i + cells[i - 1]
		if portal == t:
			print('YES')
			return
		if portal > t:
			print('NO')
			return
		i = portal
	print('NO')
inp = list(map(int, input().split()))
n = inp[0]
t = inp[1]
inp = list(map(int, input().split()))
newYear(n, t, inp)


target = [int(x) for x in input().split()][1]
areas = list(map(int, input().split()))
area_to_check = 0
while True:
	if area_to_check == target - 1:
		print('YES')
		break
	elif area_to_check > target - 1:
		print('NO')
		break
	area_to_check += areas[area_to_check]


s = str(input()).split()
n = int(s[0])
m = int(s[1])
s = str(input()).split()
x = 1
for i in range(1, n):
	if x == i:
		x += int(s[i - 1])
		if x == m:
			break
if x == m:
	print('YES')
else:
	print('NO')


(n, t) = input().split()
A = input()
B = []
for i in A.split():
	B.append(int(i))
n = int(n)
t = int(t)
p = 0
a = 0
while p < t:
	p = p + B[p]
	if p == t - 1:
		a = 1
		break
if a == 1:
	print('YES')
else:
	print('NO')


(n, t) = [int(i) for i in input().split()]
t -= 1
lst = [int(i) for i in input().split()] + [0]
flag = [False] * n
(flag[0], cur) = (True, lst[0])
while not flag[cur]:
	flag[cur] = True
	cur += lst[cur]
flag[cur] = True
if flag[t]:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
m = [int(x) for x in input().split()]
s = [0]
i = 0
while i <= n - 2:
	i = i + m[i]
	s.append(i)
if t - 1 in s:
	print('YES')
else:
	print('NO')


(n, t) = [int(i) for i in input().split()]
t -= 1
a = [int(i) for i in input().split()] + [0]
flag = [False] * n
flag[0] = True
now = a[0]
while not flag[now]:
	flag[now] = True
	now += a[now]
flag[now] = True
if flag[t]:
	print('YES')
else:
	print('NO')


(nodes, cell) = map(int, input().split())
nodeConnections = list(map(int, input().split()))

def findNode(connections, cell):
	connectionsLength = len(connections)
	currentCell = 1
	for v in nodeConnections:
		if cell == currentCell:
			return True
		elif currentCell > cell or currentCell > connectionsLength:
			return False
		currentCell += connections[currentCell - 1]
		if cell == currentCell:
			return True
	return False
print('YES' if findNode(nodeConnections, cell) else 'NO')


l = list(map(int, input().split()))
a = list(map(int, input().split()))
i = 1
while i <= l[1]:
	if i == l[1]:
		print('YES')
		break
	else:
		i = i + a[i - 1]
if i > l[1]:
	print('NO')


(n, t) = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
result = 0
i = 0
t -= 1
while i < len(A):
	current = i
	next = current + A[i]
	if next == t:
		result = 1
		break
	elif next > t:
		break
	else:
		i = next
if result == 1:
	print('YES')
else:
	print('NO')


import sys
(n, m) = map(int, input().split())
data = [int(x) for x in input().split()]
data.append(0)
k = 0
while k < m:
	k += data[k]
	if k + 1 == m:
		print('YES')
		sys.exit()
print('NO')


(n, k) = map(int, input().split())
lis = list(map(int, input().split()))
p = 1
while p < k:
	p += lis[p - 1]
if p == k:
	print('YES')
else:
	print('NO')


(n, t) = [int(i) for i in input().split(' ')]
cells = [int(i) for i in input().split(' ')]
c = 0
while c <= t - 1 and c <= n - 1:
	if c == t - 1:
		print('YES')
		quit()
	else:
		c += cells[c]
print('NO')


(n, d) = map(int, input().split())
A = list(map(int, input().split()))
a = {i + 1: A[i] for i in range(n - 1)}
i = 1
while i <= d:
	if i == d:
		print('YES')
		break
	else:
		i += a[i]
else:
	print('NO')


(n, t) = tuple(map(int, input().split()))
a = list(map(int, input().split()))
done = False
i = 1
while i <= t:
	i = i + a[i - 1]
	if i == t:
		done = True
		break
if done:
	print('YES')
else:
	print('NO')


from itertools import repeat
(n, t) = map(int, input().split())
t -= 1
reachable = list(repeat(False, n))
reachable[0] = True
for (i, a) in enumerate(map(int, input().split())):
	reachable[i + a] |= reachable[i]
print('YES' if reachable[t] else 'NO')


from collections import defaultdict
visited = [0] * 100010
graph = defaultdict(list)

def dfs(s):
	queue = []
	queue.append(s)
	visited[s] = 1
	while queue:
		s = queue.pop(0)
		for i in graph[s]:
			if visited[i] == 0:
				queue.append(i)
				visited[i] = 1
(n, t) = map(int, input().split())
j = 0
a = list(map(int, input().split()))
for i in range(1, n):
	graph[i].append(i + a[j])
	j += 1
dfs(1)
if visited[t] == 1:
	print('YES')
else:
	print('NO')


(num_cells, target) = map(lambda x: int(x), input().split())
cells = [int(i) for i in input().strip().split()]
current = 1
found = False
while current <= target:
	if current == target:
		found = True
		break
	jump = cells[current - 1]
	current += jump
if found:
	print('YES')
else:
	print('NO')


(n, t) = input().split()
(n, t) = (int(n), int(t))
lst = input().split()
for i in range(len(lst)):
	lst[i] = int(lst[i])
res = 1
while res < t:
	res = res + lst[res - 1]
if res == t:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split(' '))
ps = portals = list(map(int, input().split(' '))) + [1]
h = here = 1
a = answer = False
while h <= n:
	if h == t:
		a = True
	h += ps[h - 1]
print('YES' if a else 'NO')


import sys
import inspect
import re
import math
from pprint import pprint as pp
mod = 998244353
MAX = 10 ** 15

def deb(p):
	for line in inspect.getframeinfo(inspect.currentframe().f_back)[3]:
		m = re.search('\\bdeb\\s*\\(\\s*([A-Za-z_][A-Za-z0-9_]*)\\s*\\)', line)
		print('%s %d' % (m.group(1), p))

def main():
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	t -= 1
	i = 0
	while i < t:
		i += a[i]
		if i == t:
			print('YES')
			return
	print('NO')
main()


(n, t) = map(int, input().split())
s = list(map(int, input().split()))
v = 1
while v < n:
	v = v + s[v - 1]
	if v == t:
		print('YES')
		break
if v == n and n > t:
	print('NO')


(n, t) = map(int, input().split())
li = list(map(int, input().split()))
l = [0] + li
x = 0
i = 1
done = 0
while i < n and x < n:
	x = i + l[i]
	if x == t:
		done = 1
		break
	i = x
if done:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
ls = list(map(int, input().split()))
i = 0
canVisit = [i + 1]
while True:
	try:
		canVisit.append(i + ls[i] + 1)
		i += ls[i]
	except IndexError:
		break
if t in canVisit:
	print('YES')
else:
	print('NO')


(n, t) = list(map(int, input().split()))
a = list(map(int, input().split()))
a.insert(0, 0)
c = 1
while True:
	if c == t:
		print('YES')
		break
	elif c > t:
		print('NO')
		break
	else:
		c = c + a[c]


(N, T) = map(int, input().split())
l = list(map(int, input().split()))
flag = 0
i = 0
while i < T:
	i += l[i]
	if i == T - 1:
		flag = 1
		break
if flag:
	print('YES')
else:
	print('NO')


(n, t) = list(map(int, input().split()))
A = [0] + list(map(int, input().split()))
temp = 1
while True:
	temp += A[temp]
	if temp == t:
		print('YES')
		break
	elif temp > t:
		print('NO')
		break


from collections import defaultdict

class Graph:

	def __init__(self):
		self.graph = defaultdict(list)

	def addEdge(self, a, b):
		self.graph[a].append(b)

	def DFStrav(self, i, visited):
		visited[i] = True
		while self.graph[i] != 0:
			if i == c:
				global h
				h = 1
				break
			if len(self.graph[i]) == 0:
				break
			i = self.graph[i][0]
(n, c) = list(map(int, input().split()))
l = list(map(int, input().split()))
g = Graph()
for i in range(1, n):
	g.addEdge(i, i + l[i - 1])
visited = [False] * (2 * n)
h = 0
g.DFStrav(1, visited)
if h == 1:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
b = [0] + list(map(int, input().split()))
i = 1
while i < m:
	i += b[i]
print('YES' if i == m else 'NO')


(n, t) = map(int, input().split())
a = list(map(int, input().split())) + [0]
v = 0
good = t - 1 == v
while a[v] != 0:
	v += a[v]
	good |= t - 1 == v
print('YES' if good else 'NO')


line = input().split()
n = int(line[0])
t = int(line[1])
line = input().split()
found = False
currentCell = 1
while currentCell <= n:
	if currentCell == t:
		print('YES')
		found = True
		break
	if currentCell == n:
		break
	currentCell += int(line[currentCell - 1])
if not found:
	print('NO')


(m, t) = map(int, input().split())
line = list(map(int, input().split())) + [0]
t -= 1
point = 0
while point < t:
	point += line[point]
print('YES' if point == t else 'NO')


def check():
	if t == 1:
		print('YES')
		return
	index = 1
	while index <= t:
		if As[index - 1] + index == t:
			print('YES')
			return
		else:
			index = index + As[index - 1]
	print('NO')
(n, t) = map(int, input().split(' '))
As = list(map(int, input().split(' ')))
check()


(n, t) = input().split()
a = input().split()
i = 0
while i < int(t) - 1:
	i = i + int(a[i])
if i == int(t) - 1:
	print('Yes')
else:
	print('No')


(n, m) = map(int, input().split())
s = [int(s) for s in input().split()]
c = 0
i = 0
t = 'NO'
while i < n - 1:
	c = i + 1 + s[i]
	if c == m:
		t = 'Yes'
		break
	i = c - 1
print(t)


def main():
	line = input().split()
	n = int(line[0])
	cell = int(line[1])
	cells = input().split()
	out = 1
	i = 0
	while i < n - 1 and out < cell:
		out += int(cells[i])
		i = out - 1
	if out == cell:
		print('YES')
	else:
		print('NO')
main()


(n, t) = map(int, input().split())
for j in range(n):
	A = list(map(int, input().split()))
	break
i = 1
if i == t:
	print('YES')
S = []
while i <= n - 1:
	c = i + A[i - 1]
	S.append(c)
	(i, c) = (c, 0)
if t in S:
	print('YES')
else:
	print('NO')


nt = input().split()
n = int(nt[0])
t = int(nt[1])
A = input().split()
A = [int(i) for i in A]
B = [0 for i in range(0, n)]
B[0] = 1
k = 0
while k < n - 1:
	k += A[k]
	B[k] = 1
if B[t - 1] == 0:
	print('NO')
else:
	print('YES')


def okay(al, t):
	i = 1
	while i < t:
		i = i + al[i]
	return i == t
(n, t) = list(map(int, input().split()))
al = [0] + list(map(int, input().split()))
print('YES' if okay(al, t) else 'NO')


(n, t) = map(int, input().rstrip().split())
ai = list(map(int, input().split()))
place = 1
while place < t:
	place += ai[place - 1]
if place == t:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
li = list(map(int, input().split()))
i = 1
while True:
	if i != t and i < t:
		i += li[i - 1]
	if i == t:
		print('YES')
		break
	if i > t:
		print('NO')
		break


(n, t) = map(int, input().split())
a = [int(i) for i in input().split()]
used = (n + n) * [0]
used[1] = 1
for i in range(1, t):
	if used[i] == 0:
		continue
	if i + a[i - 1] <= t:
		used[i + a[i - 1]] = 1
if used[t] == 1:
	print('YES')
else:
	print('NO')


(n, tgt) = map(int, input().split())
a = list(map(int, input().split()))
cr = 0
tgt -= 1
while cr < tgt:
	cr += a[cr]
if cr == tgt:
	print('YES')
else:
	print('NO')


__author__ = 'Daniil'
(n, t) = list(map(int, input().split()))
a = list(map(int, input().split()))
i = 0
while i != t - 1:
	i += a[i]
	if i > t - 1:
		print('NO')
		quit()
print('YES')


f = lambda : map(int, input().split())
(n, t) = f()
an = list(f())
visit = 1
while visit < n:
	visit += an[visit - 1]
	if t == visit:
		print('YES')
		break
else:
	print('NO')


(n, t) = map(int, input().split())
cells = list(map(int, input().split()))
location = 1
while location < t:
	location += cells[location - 1]
if location == t:
	print('YES')
else:
	print('NO')


(n, t) = [int(x) for x in input().split()]
l = [int(y) for y in input().split()]
s = 1
while s < t:
	s += l[s - 1]
if s > t:
	print('NO')
else:
	print('YES')


(n, t) = map(int, input().split())
a = [0] + list(map(int, input().split()))
edges = [[] for x in range(n + 1)]
i = 1
while i != n:
	(x, y) = (i, i + a[i])
	edges.append(y)
	i = y
j = 1
f = 0
i = 1
if edges[t] == [] and t not in edges:
	print('NO')
else:
	print('YES')


def Visit(a, t):
	i = 0
	while i <= len(a) - 1:
		i += int(a[i])
		if i == t - 1:
			return True
	return False
(n, t) = input().split()
a = input().split()
if Visit(a, int(t)):
	print('YES')
else:
	print('NO')


(n, t) = list(map(int, input().split()))
a = list(map(int, input().split()))
j = 0
while j <= n - 2:
	if j == t - 1:
		break
	j = j + a[j]
if j == t - 1:
	print('YES')
else:
	print('NO')


from sys import stdin
input = stdin.readline
(n, t) = map(int, input().split())
arr = [*map(int, input().split())]
i = 0
flag = False
while i < t:
	if i == t - 1:
		flag = True
		break
	i += arr[i]
print('Yes' if flag else 'NO')


k = lambda : map(int, input().split())
(n, t) = k()
l = list(k())
a = 0
while 1:
	a = l[a] + a
	if a + 1 == t or a + 1 == n:
		break
if a + 1 == t:
	print('YES')
else:
	print('NO')


(a, b) = map(int, input().split())
l = list(map(int, input().split()))
answer = 'NO'
i = 1
while i <= a:
	if i == b:
		answer = 'YES'
		break
	if i < b:
		i += l[i - 1]
	if i > b:
		break
print(answer)


(n, t) = list(map(int, input().split()))
s = list(map(int, input().split()))
summ = 0
yes = False
if t == 1:
	print('YES')
	yes = True
i = 0
while i < len(s):
	summ += s[summ]
	i = summ
	if summ + 1 == t:
		print('YES')
		yes = True
if not yes:
	print('NO')


(n, t) = map(int, input().split())
a = list(map(int, input().split()))
if t == n:
	print('YES')
	exit()
vis = [0] * n
curr = 0
for i in range(1):
	if not vis[i]:
		curr = i
		while curr != n - 1:
			vis[curr] = 1
			curr = a[curr] + curr
if vis[t - 1]:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
arr = list(map(int, input().split()))
(arr, i, num, res) = ([0] + arr, 1, 0, 'YES')
while num != t:
	num = i + arr[i]
	if num > t or i > len(arr) - 1:
		res = 'NO'
		break
	i = num
print(res)


(n, t) = map(int, input().split())
conn = list(map(int, input().split()))
pos = 0
t -= 1
while True:
	pos += conn[pos]
	if pos == t:
		print('YES')
		break
	if pos > t:
		print('NO')
		break


(n, t) = map(int, input().split())
at = 1
portals = [None] + list(map(int, input().split()))
while at < n and at != t:
	at += portals[at]
if at == t:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
A = list(map(int, input().split()))
A = [0] + A
a = 1
while a != n:
	if a == t:
		print('YES')
		exit()
	a += A[a]
if a == t:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
A = list(map(int, input().split()))
B = []
x = 0
while True:
	try:
		B.append(x)
		x += A[x]
	except IndexError:
		break
if t - 1 in B:
	print('YES')
else:
	print('NO')


(n, k) = tuple(map(int, input().split()))
a = list(map(int, input().split()))
k = k - 1
i = 0
ok = False
while True:
	if i == k:
		ok = True
		break
	if i == n - 1:
		break
	i += a[i]
if ok:
	print('YES')
else:
	print('NO')


n = input().split()
target = int(n[1]) - 1
index = 0
a = list(map(int, input().split()))
while index < target:
	index += a[index]
if index == target:
	print('YES')
else:
	print('NO')


def connected(n, t, array):
	graph = []
	for (idx, ai) in enumerate(array):
		graph.append(idx + ai)
	possible = dfs(graph, t)
	print(possible)

def dfs(graph, t):
	stack = list()
	source = graph[0]
	if t == 0 or t == source:
		return 'YES'
	stack.append(source)
	while len(stack) != 0:
		cell = stack.pop()
		if cell < n - 1:
			if graph[cell] == t:
				return 'YES'
			elif graph[cell] > t:
				return 'NO'
		else:
			break
		stack.append(graph[cell])
	return 'NO'
(n, t) = list(map(int, input().split()))
array = list(map(int, input().split()))
connected(n, t - 1, array)


(n, t) = tuple(input().split(' '))
n = int(n)
t = int(t)
l1 = input().split(' ')
l = []
for i in l1:
	l.append(int(i))
del l1
c = 1
while c < t:
	c += l[c - 1]
if c == t:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
arr = [0] * n
arr[0] = 1
s = list(map(int, input().split()))
for i in range(n - 1):
	arr[i + s[i]] += arr[i]
print('YES' if arr[k - 1] else 'NO')


(n, t) = map(int, input().split())
a = [int(i) for i in input().split()]
p = 1
flag = True
while p <= n:
	if p == t:
		print('YES')
		flag = False
		break
	elif len(a) >= p:
		p += a[p - 1]
	else:
		break
	if p == t:
		print('YES')
		flag = False
		break
if flag:
	print('NO')


def ans():
	(n, t) = [int(i) for i in input().split()]
	a = [0]
	a += [int(i) for i in input().split()]
	ans = 1
	i = 1
	while True:
		ans += a[i]
		i = ans
		if ans == t:
			print('YES')
			return
		if i > t:
			print('NO')
			return
ans()


(n, m) = map(int, input().split())
a = [1] + list(map(int, input().split()))
x = 0
flag = False
while x < n:
	i = x + a[x]
	if i == m:
		flag = True
		break
	x = i
print('YES' if flag else 'NO')


firstLine = input().split(' ')
n = int(firstLine[0])
t = int(firstLine[1])
secondLine = input().split(' ')
cur = 1
for i in range(n):
	next = cur + int(secondLine[cur - 1])
	if next == t:
		print('YES')
		break
	elif next > t:
		print('NO')
		break
	cur = next


(n, r) = map(int, input().split())
lista = [int(x) for x in input().split()]
flag = False
i = 0
while i < n - 1:
	if i == r - 1:
		flag = True
		break
	else:
		i = lista[i] + i
if i == r - 1:
	flag = True
if flag:
	print('YES')
else:
	print('NO')


numbers = input()
numbers = list(map(int, numbers.split()))
n = numbers[0]
t = numbers[1]
answer = 'NO'
transport = input()
transport = list(map(int, transport.split()))
index = 1
while index < n:
	if index == t:
		answer = 'YES'
		break
	cellNumber = index
	cellValue = transport[index - 1]
	index = cellNumber + cellValue
if index == t:
	answer = 'YES'
print(answer)


def possible_reach(A, t):
	count = 0
	while count < t - 1:
		count += A[count]
	if count == t - 1:
		return 'YES'
	return 'NO'
(n, t) = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
print(possible_reach(A, t))


(pocet, cislo_izby) = map(int, input().split())
portaly = list(map(int, input().split()))
(izba, mozne) = (0, False)
for i in range(pocet - 1):
	portaly[i] += i
portaly.append(pocet - 1)
for i in range(pocet):
	izba = portaly[izba]
	if izba == cislo_izby - 1:
		mozne = True
		break
if mozne:
	print('YES')
else:
	print('NO')


(n, t) = map(int, input().split())
arr = [int(i) for i in input().split()]
idx = 0
while idx < t - 1:
	idx += arr[idx]
res = 'YES' if idx == t - 1 else 'NO'
print(res)


from collections import deque

def bfs(vertex):
	queue = deque([vertex])
	while queue:
		pop_vertex = queue.popleft()
		used.add(pop_vertex)
		if pop_vertex in graph:
			if graph[pop_vertex] not in used:
				queue.append(graph[pop_vertex])
(n, t) = map(int, input().split())
places = [int(i) for i in input().split()]
graph = {}
for i in range(1, n):
	graph[i] = places[i - 1] + i
used = set()
bfs(1)
print('YES' if t in used else 'NO')


a = input().split(' ')
b = input().split(' ')
line = 1
while line < int(a[0]) and line < int(a[1]):
	line = line + int(b[line - 1])
if line != int(a[1]):
	print('NO')
if line == int(a[1]):
	print('YES')


import sys
from collections import deque
fast_reader = sys.stdin.readline
fast_writer = sys.stdout.write

def input():
	return fast_reader().strip()

def print(*argv):
	fast_writer(' '.join((str(i) for i in argv)))
	fast_writer('\n')
(n, t) = map(int, input().split())
l = list(map(int, input().split()))
d = {}
for i in range(n - 1):
	d[i + 1] = l[i] + i + 1
q = deque()
q.append(1)
visited = set()
while len(q) != 0:
	pp = q.popleft()
	if pp in visited:
		continue
	else:
		visited.add(pp)
		if pp in d:
			q.append(d[pp])
if t in visited:
	print('YES')
else:
	print('NO')


def solve():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	t = 1
	i = 1
	while True:
		i = i + a[i - 1]
		if i == m:
			print('YES')
			return
		elif i > m:
			break
	print('NO')
solve()


(num_cells, wanted_cell) = map(int, input().split())
portals = list(map(int, input().split()))
cur_cell = 1
while cur_cell < wanted_cell:
	cur_cell += portals[cur_cell - 1]
print('YES' if cur_cell == wanted_cell else 'NO')


nt = input().split()
(n, t) = (int(nt[0]), int(nt[1]))
portals = iter(map(int, input().split()))
current = 1
for i in portals:
	if current < t:
		current += i
		for z in zip(range(i - 1), portals):
			pass
	elif current == t:
		print('YES')
		break
	else:
		print('NO')
		break
else:
	if current == t:
		print('YES')
	else:
		print('NO')


(n, m) = [int(x) for x in input().split()]
ar = [0] + [int(x) for x in input().split()]
k = 1
while k < m:
	k += ar[k]
print('YES' if k == m else 'NO')


(n, t) = map(int, input().split())
m = list(map(int, input().split()))
i = 1
while i < t:
	v = m[i - 1]
	i += v
print('YES' if i == t else 'NO')