atcoder#ARC093A. [ABC092C] Traveling Plan

[ABC092C] Traveling Plan

Score : 300300 points

Problem Statement

There are NN sightseeing spots on the xx-axis, numbered 1,2,...,N1, 2, ..., N. Spot ii is at the point with coordinate AiA_i. It costs ab|a - b| yen (the currency of Japan) to travel from a point with coordinate aa to another point with coordinate bb along the axis.

You planned a trip along the axis. In this plan, you first depart from the point with coordinate 00, then visit the NN spots in the order they are numbered, and finally return to the point with coordinate 00.

However, something came up just before the trip, and you no longer have enough time to visit all the NN spots, so you decided to choose some ii and cancel the visit to Spot ii. 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 00 at the beginning and the end, as planned.

For each i=1,2,...,Ni = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot ii is canceled.

Constraints

  • 2N1052 \leq N \leq 10^5
  • 5000Ai5000-5000 \leq A_i \leq 5000 (1iN1 \leq i \leq N)
  • All input values are integers.

Input

Input is given from Standard Input in the following format:

NN

A1A_1 A2A_2 ...... ANA_N

Output

Print NN lines. In the ii-th line, print the total cost of travel during the trip when the visit to Spot ii is canceled.

3
3 5 -1
12
8
10

Spot 11, 22 and 33 are at the points with coordinates 33, 55 and 1-1, respectively. For each ii, the course of the trip and the total cost of travel when the visit to Spot ii is canceled, are as follows:

  • For i=1i = 1, the course of the trip is 05100 \rightarrow 5 \rightarrow -1 \rightarrow 0 and the total cost of travel is 5+6+1=125 + 6 + 1 = 12 yen.
  • For i=2i = 2, the course of the trip is 03100 \rightarrow 3 \rightarrow -1 \rightarrow 0 and the total cost of travel is 3+4+1=83 + 4 + 1 = 8 yen.
  • For i=3i = 3, the course of the trip is 03500 \rightarrow 3 \rightarrow 5 \rightarrow 0 and the total cost of travel is 3+2+5=103 + 2 + 5 = 10 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