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.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public int[] A;

        public void Run()
        {
            {
                N = Input.ReadInt();
                A = Input.ReadIntArray();
            }

            long total = 0;
            for(int i = 0; i <= N; i++)
            {
                int fr = i == 0 ? 0 : A[i-1];
                int to = i == N ? 0 : A[i];
                total += Math.Abs(to - fr);
            }

            int[] S = new int[N];
            for (int i = 0; i < N; i++)
            {
                int fr = i == 0 ? 0 : A[i - 1];
                int md = A[i];
                int to = i == N - 1? 0 : A[i + 1];

                S[i] = Math.Abs(to - md) + Math.Abs(md - fr) - Math.Abs(to - fr);
            }

            for(int i = 0; i < N; i++)
                Console.WriteLine(total - S[i]);

        }
    }

    // libs ----------
    internal class SegTree
    {
        public static bool DEBUG = false;

        public int N;
        public int NCells;
        public int H;
        public int?[] Data;
        public int[] Min;
        public int[] KL; // 範囲のbegin
        public int[] KR; // 範囲のend（そのセルは含まない）

        public SegTree(int _n)
        {
            Init(_n);
        }

        private int GetN(int _n)
        {
            int n = 1;
            H = 1;
            while (n < _n)
            {
                n *= 2;
                H++;
            }
            return n;
        }

        private void Init(int _n)
        {
            N = GetN(_n);
            NCells = 2 * N - 1;

            Data = new int?[NCells];
            Min = new int[NCells];

            KL = new int[NCells];
            KR = new int[NCells];

            // KL, KRの初期化
            for (int k = 0; k < NCells; k++)
            {
                if (IsRoot(k))
                {
                    KL[k] = 0;
                    KR[k] = N;
                }
                else
                {
                    if (IsChildL(k))
                    {
                        KL[k] = KL[Parent(k)];
                        KR[k] = (KL[Parent(k)] + KR[Parent(k)]) / 2;
                    }
                    else
                    {
                        KL[k] = (KL[Parent(k)] + KR[Parent(k)]) / 2;
                        KR[k] = KR[Parent(k)];
                    }
                }
            }

            // 値の初期化
            for (int k = 0; k < NCells; k++)
            {
                Data[k] = null;
                Min[k] = 2147483647;
            }

            // 全体に初期値をセット
            Update(0, N, 2147483647);
        }

        // i番目のみの値を保持するセル
        public int Pos(int i) { return i + N - 1; }

        // 親セル・子セル
        public int Parent(int k) { return (k - 1) / 2; }
        public int ChildL(int k) { return k * 2 + 1; }
        public int ChildR(int k) { return k * 2 + 2; }

        // 根かどうか
        public bool IsRoot(int k) { return k == 0; }

        // 左側の子かどうか
        public bool IsChildL(int k)
        {
            if (IsRoot(k)) return false;
            return ChildL(Parent(k)) == k;
        }
        
        // Update - top down
        public void Update(int il, int ir, int a)
        {
            update(il, ir, 0, a);

            if (DEBUG)
            {
                Console.WriteLine("--------------");
                int c = 2;
                for (int i = 0; i < NCells; i++)
                {
                    if (i == c - 1)
                    {
                        Console.WriteLine();
                        c *= 2;
                    }
                    Console.Write(Data[i] + " ");
                }
                Console.WriteLine();
                Console.WriteLine("--------------");
            }
        }

        private void update(int il, int ir, int k, int a)
        {
            int kl = KL[k];
            int kr = KR[k];

            if (kr <= il || ir <= kl) return;

            // 完全に重複している場合にその値をセット
            if (il <= kl && kr <= ir)
            {
                Data[k] = a;
                Min[k] = a;
            }
            else
            {
                // そうでない場合、上の値を分配
                // Minの更新も必要
                if (Data[k] != null)
                {
                    Data[ChildL(k)] = Data[k];
                    Data[ChildR(k)] = Data[k];
                    Min[ChildL(k)] = Data[k].Value;
                    Min[ChildR(k)] = Data[k].Value;
                    Data[k] = null;
                    
                }

                // 子の処理を行う
                update(il, ir, ChildL(k), a);
                update(il, ir, ChildR(k), a);
                Min[k] = MinValue(Min[ChildL(k)], Min[ChildR(k)]);

            }

        }

        // Query - bottom up
        public int Query(int s, int t)
        {
            return query(s, t + 1, 0).Value;
        }

        private int? query(int il, int ir, int k)
        {
            int kl = KL[k];
            int kr = KR[k];

            // 重複が無いケース
            if (kr <= il || ir <= kl) return null;

            // 完全に重複している場合
            if (il <= kl && kr <= ir)
                return Min[k];
            else
            {
                // 完全に重複していない場合

                // Dataに値がある場合はそのMinを使って良い（Dataに値があるかどうかがフラグになっている）
                if (Data[k] != null) return Min[k];

                // そうでない場合、子の処理を行う
                int? l = query(il, ir, ChildL(k));
                int? r = query(il, ir, ChildR(k));
                return MinValue(l, r);
            }
        }

        private int MinValue(int? l, int? r)
        {
            if(l == null && r == null) throw new Exception();
            if (l == null) return r.Value;
            if (r == null) return l.Value;
            return Math.Min(l.Value, r.Value);
        }
    }

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}