#CCBCHBAHAI0000149. Bãi đỗ xe (Parking)
Bãi đỗ xe (Parking)
Parking
Source: Kattis
Version: Phuoc Hung OJ Extended
Problem Statement
A street is represented by an integer number line. Michael must visit stores, and store is at integer position . He parks his car at one position and must return to the car after visiting all stores.
Compute the minimum total walking distance needed to visit all stores and return to the parked car.
Input
- The first line contains an integer , the number of stores.
- The second line contains integers , the store positions.
Output
Print one integer, the minimum walking distance.
Subtasks
Subtask 1 (100 points): and .
Examples
Input
4
24 13 89 37
Output
152
Explanation
The leftmost store is at and the rightmost at . Visiting all stores and returning to the car requires covering the interval of length in both directions, so the minimum distance is .