Problem Description
Otabek prefers to drink only pure water, specifically he likes one particular brand of bottled water. But it turned out that the factory producing this drink has closed down, and now it cannot be found in any store. However, Otabek still has not come to terms with this fact, so he decided to visit every store in his city in search of this water.
The city where Otabek lives can be represented as a number line ranging from to . It is known that there are a total of stores in the city. The order in which Otabek will visit the stores is given by a list of integers, where the element () corresponds to the position of the -th store.
Otabek will visit the stores as follows:
- Otabek starts at point ;
- He walks from point to point , increasing the total distance by ;
- He walks from point to point , increasing the total distance by ;
Your task is to calculate the total distance that Otabek will walk. The distance traveled from point to point is equal to .
Input
In the first line, you are given the number of stores () and the range of the city ().
In the second line, integers () are given — the positions and order of the stores, all stores are distinct, note that a store can also be located at point .
Output
Output a single number — the total distance that Otabek will walk.
Scoring System
| Group | Additional Constraints | Points | Required Subgroups |
|---|---|---|---|
| 0 | Tests from the statement | 0 | — |
| 1 | 5 | 0 | |
| 2 |
Examples
1 10 5
10
5 10 2 3 -6 -2 10
38