#t445. 奇怪的电梯

奇怪的电梯

The Strange Elevator

Problem Background

Special for beginners, ^_^

Problem Description

Each floor of the building can stop the elevator, and the ii-th floor (1≤i≤N1\le i\le N) has a number Ki (0≤Ki≤N)K_i\ (0\le K_i\le N).

The elevator has only four buttons: open, close, up, down. The number of floors moved up or down equals the number on the current floor.

Of course, if the requirement cannot be met, the corresponding button will not work. For example: 3 3 1 2 5 represents KiK_i (K1=3,K2=3,…K_1=3, K_2=3, \dots), starting from the 11st floor. On the 11st floor, pressing up goes to the 44th floor; pressing down does not work, because there is no −2-2nd floor.

Then, from floor AA to floor BB, what is the minimum number of button presses?

Input Format

The input has two lines. The first line contains three space-separated positive integers N,A,BN,A,B (1≤N≤2001\le N\le 200, 1≤A,B≤N1\le A,B\le N). The second line contains NN space-separated positive integers, representing KiK_i.

Output Format

Output a single line: the minimum number of button presses. If unreachable, output −1-1.

Sample Input 1

5 1 5
3 3 1 2 5

Sample Output 1

3

Constraints

Time limit 1s, memory limit 1024KiB for each test case.