Олимпиадный тренинг

Задача 38752. Andrew and portals


Задача

Темы:
Andrey is about to be late for the school stage of the High School. Fortunately, portals have recently appeared in his city.
The city where Andrei lives can be represented as a straight line. In total, N portals have been built in the city. Portal number i is located at the point with coordinate xi . If at the current time you are at the same point with some portal, then in just one second you can teleport to any other portal, regardless of the distance between them. A time required to overcome the distance between points with coordinates p and q without using portals is equal to |p − q| seconds. Andrey is a powerful citizen, so he can use the portal system any number of times.
Initially Andrey is at the point s, and the point of the Olympiad has the coordinate e.
Help Andrey understand how quickly he can get to the Olympics, because every second counts.

Input
The first line of the input contains one integer s — Andrey's starting position.
The second line contains a single integer e — venue of the Olympiad. 
The third line contains the number of portals N (2 ≤ N ≤ 2 · 105).
Each of the next N lines contains an integer xi — portal coordinate with number i.
All numbers s, e, xi do not exceed 108.

Imprint
Print one number — the minimum number of seconds it takes Andrey to get to the venue of the Olympiad.
 
Examples
# Input Output
1 0
4
3
1
3
5
3


Remark
Consider an example from the condition. If Andrei could not use the portals, he could get to the point of the Olympiad for |0 − 4| = 4 seconds. However, you can do it like this:
1. Get to the portal with number 1 for |0 − 1| = 1 second.
2. Teleport to portal number 2 in one second.
3. Get from the portal with number 2 to the point of the Olympiad for |3 − 4| = 1 second.
In total we get 1 + 1 + 1 = 3 seconds.