Hide

Problem B
Elevating the Prank

After Loke beat you in last week’s programming competition you want play a prank on him. You both live in the same student apartment and in order to get from floor $A$ to floor $B$, Loke (who is very lazy) of course wants to take the elevator. You want him to suffer as long as possible inside the elevator and therefore you have pressed $N$ different floors that the elevator should stop at.

The elevator stops for $10$ seconds on each floor that it stops on. Opening and closing the elevator doors is instant. It takes $4$ seconds for the elevator to move from one floor to another.

Input

The first line of input contains two integers, $A$ and $B$ ($-10 \leq A, B \leq 50$), the origin and destination floors for Loke. The next line of input contains one integer, $N$ ($0 \leq N \leq 60$), the number of floors you have pressed. The following $N$ lines each contain one integer, $a_ i$ ($-10 \leq a_ i \leq 50$), the floors the elevator will stop at.

Output

Print one integer, the number of seconds Loke has to suffer inside the elevator, from the doors closing on floor $A$ to the doors opening on floor $B$.

Explanation of Sample 2

The elevator will move $8$ floors in total, from floor $0$ to floor $8$. This takes $32$ seconds. Among the floors that you have pressed for the elevator to stop, only floor $5$ is between $0$ and $8$. The time for the doors to open and close on floor $0$ and $8$ is zero, so it does not affect the answer. In total, Loke will spend $42$ seconds inside the elevator.

Sample Input 1 Sample Output 1
1 5
5
2
4
5
3
1
46
Sample Input 2 Sample Output 2
0 8
10
-10
-5
0
5
10
15
20
25
30
35
42
Sample Input 3 Sample Output 3
10 0
3
5
1
10
60

Please log in to submit a solution to this problem

Log in