Problem:
Score : 300 points

Problem Statement

There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N.
Spot i is at the point with coordinate A_i.
It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis.

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

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

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

Constraints

2 \leq N \leq 10^5

-5000 \leq A_i \leq 5000 (1 \leq i \leq N)

All input values are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 ... A_N

Output

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

Sample Input 1

3
3 5 -1

Sample Output 1

12
8
10

Spot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.
For each i, the course of the trip and the total cost of travel when the visit to Spot i is canceled, are as follows:

For i = 1, the course of the trip is 0 \rightarrow 5 \rightarrow -1 \rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.

For i = 2, the course of the trip is 0 \rightarrow 3 \rightarrow -1 \rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.

For i = 3, the course of the trip is 0 \rightarrow 3 \rightarrow 5 \rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.

Sample Input 2

5
1 1 1 2 0

Sample Output 2

4
4
4
2
4

Sample Input 3

6
-679 -2409 -3258 3095 -3291 -4462

Sample Output 3

21630
21630
19932
8924
21630
19288

Solution in C# (Mono 4.6.2.0) (judge verdict: Accepted)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CompetitiveProgCsLib
{
	class MainProg
	{
		static string R => Console.ReadLine();
		static int RI => int.Parse(R);
		static double RD => double.Parse(R);
		static int[] RIs => R.Split(' ').Select(int.Parse).ToArray();
		static double[] RDs => R.Split(' ').Select(double.Parse).ToArray();
		static void Out(object obj) => Console.WriteLine(obj);
		static void Outb(bool b) => Out(b ? "Yes" : "No");
		static void OutB(bool b) => Out(b ? "YES" : "NO");

		static void Main(string[] args)
		{
			var N = RI;
			var A = RIs;
			var Ap = new List<int>();
			Ap.Add(0);
			Ap.AddRange(A);
			Ap.Add(0);
			var li = new List<int>();
			SegmentTree<int> seg = new SegmentTree<int>(Ap.Count, (x, y) => x + y);
			for (int i = 1; i < Ap.Count; i++)
			{
				seg.Update(i - 1, Math.Abs(Ap[i] - Ap[i - 1]));
			}
			for (int i = 0; i < N; i++)
			{
				var a = seg[i];
				var b = seg[i + 1];
				seg.Update(i, 0);
				seg.Update(i + 1, Math.Abs(Ap[i + 2] - Ap[i]));
				Out(seg.Evaluate(0, seg.Length));
				seg.Update(i, a);
				seg.Update(i + 1, b);
			}
		}
	}

	public class SegmentTree<T>
	{
		#region member
		/// <summary>
		/// 評価する演算子
		/// </summary>
		private Func<T, T, T> associativeOperation;
		/// <summary>
		/// データを保存する木構造
		/// </summary>
		private T[] tree;
		/// <summary>
		/// 単位元
		/// </summary>
		private T identityElement;
		/// <summary>
		/// tree[origin]に元の数列の先頭がある
		/// </summary>
		private int origin;
		#endregion

		#region property
		/// <summary>
		/// 配列の長さ
		/// </summary>
		public int Length
		{
			get;
			private set;
		}
		/// <summary>
		/// 現在の配列を返す
		/// </summary>
		/// <param name="index"></param>
		/// <returns></returns>
		public T this[int index]
		{
			get
			{
				return tree[origin + index];
			}
			private set
			{
				tree[origin + index] = value;
			}
		}
		#endregion

		#region private method
		private T evaluate(int a, int b, int k, int l, int r)
		{
			if (r <= a || b <= l) return identityElement;
			if (a <= l && r <= b) return tree[k];
			else
			{
				T val_l = this.evaluate(a, b, k * 2 + 1, l, (l + r) / 2);
				T val_r = this.evaluate(a, b, k * 2 + 2, (l + r) / 2, r);
				return associativeOperation.Invoke(val_l, val_r);
			}
		}
		#endregion

		#region constructor
		public SegmentTree(int n, Func<T, T, T> operation, T identity = default(T)) : this((new T[n]).Select(x => x = identity).ToArray(), operation, identity)
		{
		}

		public SegmentTree(T[] array, Func<T, T, T> operation, T identity = default(T))
		{
			Length = array.Length;
			associativeOperation = operation;
			int size = 1 << (int)Math.Ceiling(Math.Log(Length, 2));
			identityElement = identity;
			tree = (new T[size * 2 - 1]).Select(x => x = identityElement).ToArray();
			origin = tree.Length - size;
			for (int i = 0; i < array.Length; i++)
			{
				this[i] = array[i];
			}
			for (int i = origin - 1; i >= 0; i--)
			{
				tree[i] = associativeOperation.Invoke(tree[i * 2 + 1], tree[i * 2 + 2]);
			}
		}
		#endregion

		#region public method
		/// <summary>
		/// indexの位置の値をvalueに更新する
		/// </summary>
		/// <param name="index"></param>
		/// <param name="value"></param>
		public void Update(int index, T value)
		{
			this[index] = value;
			int position = origin + index;
			while (position > 0)
			{
				position = (position - 1) / 2;
				tree[position] = associativeOperation.Invoke(tree[position * 2 + 1], tree[position * 2 + 2]);
			}
		}

		/// <summary>
		/// a &lt;= x &lt; b の区間において評価を行う
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <returns></returns>
		public T Evaluate(int a, int b)
		{
			var ret = evaluate(a, b, 0, 0, (tree.Length + 1) / 2);
			return ret;
		}
		#endregion
	}
}