#T629. 奇怪的电梯
奇怪的电梯
Description
Each floor of the building can be accessed by the elevator, and there is a number Ki (0 ≤ Ki ≤ N) on the i-th floor (1 ≤ i ≤ N). The elevator has only four buttons: open, close, up, and down. The number of floors moved up or down equals the number on the current floor. Of course, if the request cannot be satisfied, the corresponding button will not work. For example: 3 3 1 2 5 represents Ki (K1=3, K2=3, ...), starting from the first floor. On the first floor, pressing "up" will take you to the 4th floor, while pressing "down" will have no effect because there is no -2nd floor. So, how many button presses are needed at minimum to go from floor A to floor B?
Input Format
The input file consists of two lines. The first line contains three space-separated positive integers, representing N, A, B (1 ≤ N ≤ 200, 1 ≤ A, B ≤ N). The second line contains N space-separated positive integers, representing Ki.
Output Format
The output file contains only one line, which is the minimum number of button presses required. If it is impossible to reach the destination, output -1.
```input1 5 1 5 3 3 1 2 5 ``` ```output1 3 ``` ```markdown ## SourceCodesOnline