Bob has finished his shopping spree, and is now thinking about trick-or-treating on Halloween. He plans to be trick-or-treating on his street, which has evenly spaced houses numbered 1 to all on one line, each one unit apart. Bob currently lives in house number , and will start there. He wants to plan his path to get to all the houses that will be giving out candy so that on Halloween so that he is familiar with the path.
He knows that there are exactly houses giving out candy along his street (Bob's house can also be giving out candy), where the -th house has a house number of . He wants to see how far he must walk to visit each of these houses at least once, and so he decides to walk the path. However, once he reaches each house at least once, he will simply drive home. Help Bob figure out far he must walk to visit each house that is giving out candy at least once.
Input Specifications
The first line will contain an integer , denoting the number of houses.
The next line will be the integer , denoting Bob's house number (where he will start his walk).
The next line will contain an integer , denoting the number of houses that are giving out candy.
The next line will contain integers, , denoting the houses that are giving out candy, each separated by a single space.
Output Specifications
On a single line, output the minimal distance Bob has to walk to visit each house that is giving out candy exactly once.
Subtasks
Subtask 1 [20%]
Subtask 2 [80%]
No additional constraints
Sample Input 1
10
3
4
8 7 4 6
Sample Output 1
5
Explanation for Sample Output 1
Bob will start his walk at house number 3, and can walk to house number 8. By walking from 3 to 8, he passes through house number 4, 6, and 7. At this point, he has visited all the houses that plan to give out candy at least once, and so he ends his walk there after walking a distance of .
Sample Input 2
50
21
5
23 7 13 31 45
Sample Output 2
52
Explanation for Sample Output 2
Bob will start his walk at house number 21, and can walk to house number 7. By walking from house 21 to house 7, he passes through house 13 as well. Then, he can walk to house 45, which passes through houses 23 and 31 along the way. At this point, he has visited each house at least once. In total, he walked from 21 to 7 to 45, which is a total distance of . An alternate route of walking to 45 first then to 7 requires a total distance of 62, however this is farther than needed.
Sample Input 3
1000
100
3
98 100 101
Sample Output 3
4
Comments