atcoder#ARC093A. [ABC092C] Traveling Plan
[ABC092C] Traveling Plan
Score : points
Problem Statement
There are sightseeing spots on the -axis, numbered . Spot is at the point with coordinate . It costs yen (the currency of Japan) to travel from a point with coordinate to another point with coordinate along the axis.
You planned a trip along the axis. In this plan, you first depart from the point with coordinate , then visit the spots in the order they are numbered, and finally return to the point with coordinate .
However, something came up just before the trip, and you no longer have enough time to visit all the spots, so you decided to choose some and cancel the visit to Spot . You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate at the beginning and the end, as planned.
For each , find the total cost of travel during the trip when the visit to Spot is canceled.
Constraints
- ()
- All input values are integers.
Input
Input is given from Standard Input in the following format:
Output
Print lines. In the -th line, print the total cost of travel during the trip when the visit to Spot is canceled.
3
3 5 -1
12
8
10
Spot , and are at the points with coordinates , and , respectively. For each , the course of the trip and the total cost of travel when the visit to Spot is canceled, are as follows:
- For , the course of the trip is and the total cost of travel is yen.
- For , the course of the trip is and the total cost of travel is yen.
- For , the course of the trip is and the total cost of travel is yen.
5
1 1 1 2 0
4
4
4
2
4
6
-679 -2409 -3258 3095 -3291 -4462
21630
21630
19932
8924
21630
19288