Jump Jump 2

Given a walk that adds or subtracts A_i at each step, count the stones reachable from start s, excluding s unless a cycle returns to it.

Medium5GraphBFSImplementationMathInterviewNo attempts yetTime limit2sMemory limit512 MB

Problem

Youngwoo the frog is on a stone bridge made of nn stones in a row. The stones are numbered 11 to nn from the left, and stone ii has a single number AiA_i written on it. From stone ii Youngwoo can jump exactly AiA_i stones to the left or to the right, landing on stone iAii - A_i or on stone i+Aii + A_i. He cannot jump to a position numbered below 11 or above nn.

Youngwoo starts on stone ss. There is no limit on the number of jumps, and he may land on the same stone more than once. Call a stone visitable if Youngwoo can land on it after one or more jumps. The starting stone ss is visitable only when he can land back on it after at least one jump.

Count the visitable stones.

Input

The first line contains the number of stones nn (1n1000001 \le n \le 100000).

The second line contains A1,A2,,AnA_1, A_2, \dots, A_n, separated by spaces (1Ai1000001 \le A_i \le 100000).

The third line contains the starting position ss (1sn1 \le s \le n).

Output

Print the number of visitable stones on the first line.