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 (Python):
import sys

N = int(input())

A = list(map(int, input().split()))
A.insert(0, 0)
A.append(0)

sum = 0
for i in range(1, N+2):
    sum += abs(A[i]-A[i-1])

for i in range(1, N+1):
    print(sum+abs(A[i-1]-A[i+1])-abs(A[i-1]-A[i])-abs(A[i]-A[i+1]))

Solution (Python):
n = int(input())
lst = list(map(int,input().split()))

s = 0
diff_lst = []
sign_lst = []
for i in lst + [0]:
    diff = i - s
    diff_lst.append(abs(diff))
    sign_lst.append(1) if diff > 0 else sign_lst.append(-1)
    s = i

su = sum(diff_lst)
for i in range(n):
    if sign_lst[i] * sign_lst[i+1] > 0:
        print(su)
    else:
        print(su - diff_lst[i] - diff_lst[i+1] + abs(diff_lst[i] - diff_lst[i+1]))

Solution (Python):
n = int(input())
a = list(map(int, input().split()))














a.insert(0,0)
a.append(0)
def cumulative_sum(collection):
    result = [0]
    for i in range(1, len(collection)):
        item = abs(collection[i] - collection[i-1])
        result.append(result[-1] + item)
    return result
cuma = cumulative_sum(a)

lp=cuma[-1]

for i in range(n):
    gap=abs(cuma[i+2]-cuma[i])-abs(a[i+2]-a[i])
    print(lp-gap, flush=True)

Solution (Python):
n = int(input())
A = [0]
a = list(map(int, input().split()))
for a_ in a:
    A.append(a_)
s = 0
A.append(0)
for i in range(n+1):
    s += abs(A[i+1]-A[i])

for i in range(1, n+1):
    print(s + abs(A[i+1]-A[i-1]) - (abs(A[i+1]-A[i]) + abs(A[i]-A[i-1])))

Solution (Python):
N = int(input())
N_List = [0] +list(map(int,input().split())) + [0]
N_Diff_List = []

for i in range(N+1):
    N_Diff_List.append(abs(N_List[i+1]-N_List[i]))

sumans = sum(N_Diff_List)
for i in range(N):
    ans = sumans -(N_Diff_List[i] + N_Diff_List[i+1])
    ans += abs(N_List[i+2]-N_List[i])
    print(ans)

Solution (Python):
n = int(input())
a = [int(t) for t in input().split()]
a.insert(0,0)
a.append(0)
s = 0
for i in range(1,n+2):
  s += abs(a[i-1] - a[i])
for i in range(1,n+1):
  if a[i-1] <= a[i] <= a[i+1] or a[i-1] >= a[i] >= a[i+1]:
    print(s)
  else:
    res = s
    res -= abs(a[i-1] - a[i])
    res -= abs(a[i] - a[i+1])
    res += abs(a[i-1] - a[i+1])
    print(res)

Solution (Python):

"""
Created on Tue Sep 22 16:34:00 2020

@author: liang
"""

N = int(input())
A = [0]+[int(x) for x in input().split()]+[0]
ans = 0
for i in range(N+1):
    ans += abs(A[i+1] - A[i])

for i in range(1,N+1):
    tmp = ans
    if A[i-1] <= A[i] <= A[i+1]:
        print(tmp)
    elif A[i-1] >= A[i] >= A[i+1]:
        print(tmp)
    else:
        tmp -= min(abs(A[i] - A[i-1]),abs(A[i+1] - A[i]))*2
        print(tmp)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
D1 = []
D2 = []

D1.append(abs(A[0]))
D2.append(abs(A[1]))

for i in range(1,N):
  D1.append(abs(A[i]-A[i-1]))
D1.append(abs(A[N-1]))

for i in range(1,N-1):
  D2.append(abs(A[i+1]-A[i-1]))
D2.append(abs(A[N-2]))

S = sum(D1)

for i in range(N):
  print(S-D1[i]-D1[i+1]+D2[i])

Solution (Python):
from itertools import accumulate
N = int(input())
A = [0] + list(map(int, input().split())) + [0]
cost = sum(abs(A[i+1] - A[i]) for i in range(N+1))
for i in range(1, N+1):
    print(cost + abs(A[i+1] - A[i-1]) - abs(A[i-1] - A[i]) - abs(A[i] - A[i+1]))

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
a=[0]+a+[0]
cnt=0
for i in range(1,n+2):
  cnt+=abs(a[i]-a[i-1])

for i in range(1,n+1):
  print(cnt-abs(a[i-1]-a[i])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]))

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

cost = abs(a[0])
for i in range(1,n):
    cost += abs(a[i]-a[i-1])

cost+=abs(a[-1])
ans = [0]*n


an =  cost - abs(a[1]-a[0])-abs(a[0])+abs(a[1])

print(an)
for i in range(1,n-1):
    key = cost-abs(a[i-1]-a[i])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1])
    
    print(key)
print(cost-abs(a[-1])+abs(a[-2])-abs(a[-1]-a[-2]))

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
A.append(0)
A.insert(0,0)
S = 0

for i in range(len(A)-1):
    S+=abs(A[i+1]-A[i])
    
for i in range(1,N+1):
    print(S-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1]))

Solution (Python):
n = int(input())
s = [0] + list(map(int, input().split()))
s.append(0)
forward = []
backward = []
jump = []
for a, b, c in zip(s, s[1:], s[2:]):
    forward.append(abs(b - a))
    backward.append(abs(c - b))
    jump.append(abs(c - a))
res = sum(forward) + backward[-1]
for i in range(n):
    print(res + jump[i] - forward[i] - backward[i])

Solution (Python):
N = int(input())
A = [0] + list(map(int, input().split())) + [0]

all = 0
for i in range(1, N + 2):
    all += abs(A[i] - A[i - 1])

for i in range(1, N + 1):
    tmp = all
    tmp -= abs(A[i] - A[i - 1]) + abs(A[i + 1] - A[i])
    tmp += abs(A[i + 1] - A[i - 1])
    print(tmp)

Solution (Python):
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

def main():
    n = i_input()
    a = i_list()

    total = 0
    now = 0
    for i in a:
        total += abs(now-i)
        now = i
    total += abs(i)
    a.insert(0,0)
    a.append(0)

    ans = []

    for i,k in enumerate(a[1:-1], start=1):
        

        if a[i-1] <= k and k <= a[i+1] or a[i-1] >= k and  k >= a[i+1]:
            ans.append(total)
        else:
            ans.append(total - abs(k-a[i-1]) - abs(k-a[i+1]) + abs(a[i-1]-a[i+1]))

    for i in ans:
        print(i)




if __name__=="__main__":
    main()

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
A.insert(0,0)
A.append(0)
x=0
for i in range(0,N+1):
    x+=abs(A[i+1]-A[i])
for i in range(1,N+1):
    print(x-abs(A[i]-A[i-1])-abs(A[i]-A[i+1])+abs(A[i+1]-A[i-1]))

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
A.insert(0,0)
A.append(0)
x=0
for i in range(0,N+1):
    x+=abs(A[i+1]-A[i])
for i in range(1,N+1):
    print(x-abs(A[i]-A[i-1])-abs(A[i]-A[i+1])+abs(A[i+1]-A[i-1]))

Solution (Python):
import sys



def input():
    return sys.stdin.readline().rstrip()


def main():
    N=int(input())
    A=list(map(int,input().split()))
    A.append(0)
    len =0
    previous=0

    for i in range(N+1):
        len += abs(A[i] - previous)
        previous =A[i]


    previous =0
    for i in range(N):
        print(len -abs(A[i]-previous)-abs(A[i+1]-A[i])+abs(A[i+1] -previous))
        previous =A[i]







if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
A = [0] + list(map(int, input().split())) + [0]
B = []
C = []
for i in range(1, N+2):
  B.append(abs(A[i] - A[i-1]))
  if i >= 2:
    C.append(abs(A[i] - A[i-2]))
S = sum(B)
for i in range(1, N+1):
  print(S - B[i-1] - B[i] + C[i-1])

Solution (Python):
N = int(input())
A = [0] + list(map(int, input().split())) + [0]

len = []
for i in range(N+1):
    len.append(abs(A[i+1]-A[i]))

sum = sum(len)
ans = sum

for i in range(N):
    ans -= (len[i]+len[i+1])
    ans += abs(A[i+2]-A[i])
    print(ans)
    ans = sum

Solution (Python):
def main():
    n = int(input())
    a_lst = list(map(int, input().split()))

    a_lst.insert(0, 0)
    a_lst.append(0)
    lst = []
    for i in range(n + 1):
        lst.append(abs(a_lst[i + 1] - a_lst[i]))

    tmp = sum(lst)
    tmp1 = sum(lst)
    answer_lst = []
    for i in range(n):
        for j in range(2):
            tmp1 -= lst[i + j]

        tmp1 += abs(a_lst[i + 2] - a_lst[i])
        answer_lst.append(tmp1)
        tmp1 = tmp

    for i in range(n):
        print(answer_lst[i])


if __name__ == '__main__':
    main()

Solution (Python):
N=int(input())
a=[0]+list(map(int,input().split()))+[0]
sm = 0
for i in range(1,N+2):
    sm += abs(a[i-1]-a[i])
for i in range(1,N+1):
    print(sm-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i-1]-a[i+1]))

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a = [0] + a + [0]
n = len(a)

iCost = [0]*(n-1)
for i in range(n-1):
    iCost[i] = abs(a[i+1]-a[i])

totCost = sum(iCost)

modCost = [0]*n 
modCost[1] = abs(a[2])
for i in range(2, n-1):
    modCost[i] = abs(a[i+1]-a[i-1])

for i in range(1, n-1):
    print(totCost - iCost[i-1] - iCost[i] + modCost[i])

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
A = [0] + A + [0]

cost = [0] * (N + 2)
for i in range(N+1):
  cost[i] += abs(A[i+1] - A[i])
  
sum_money = sum(cost)
  
skip = [0] * N
for j in range(N):
  skip[j] += abs(A[j+2] - A[j])
  
for k in range(N):
  print(sum_money - (cost[k] + cost[k+1]) + skip[k])

Solution (Python):
n = int(input())
arr = [0] + list(map(int, input().split())) + [0]
sum_arr = sum(abs(arr[i] - arr[i+1]) for i in range(n+1))

for i in range(1, n+1):
    diff = abs(arr[i-1] - arr[i]) + abs(arr[i] - arr[i+1])\
               - abs(arr[i-1] - arr[i+1])
    print(sum_arr - diff)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
j = abs(A[0]) + abs(A[N-1])
for i in range(N-1):
    j += abs(A[i]-A[i+1])
for i in range(N):
    if i == 0:
        ans = j-abs(A[0])-abs(A[0]-A[1])+abs(A[1])
    elif i == N-1:
        ans = j-abs(A[N-2]-A[N-1])-abs(A[N-1])+abs(A[N-2])
    else:
        ans = j - abs(A[i]-A[i-1]) - abs(A[i]-A[i+1]) + abs(A[i-1]-A[i+1])
    print(ans)

Solution (Python):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.append(0)

    base = abs(a[0])
    for i in range(n):
        base += abs(a[i+1] - a[i])
    
    ans = []
    for i in range(n):
        if (a[i] - a[i-1]) * (a[i+1] - a[i]) >= 0:
            ans.append(base)
        else:
            ans.append(base - 2 * min(abs(a[i] - a[i-1]), abs(a[i+1] - a[i])))
    
    for i in ans:
        print(i)

main()

Solution (Python):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.append(0)

    base = abs(a[0])
    for i in range(n):
        base += abs(a[i+1] - a[i])
    
    ans = []
    for i in range(n):
        if (a[i] - a[i-1]) * (a[i+1] - a[i]) >= 0:
            ans.append(base)
        else:
            ans.append(base - 2 * min(abs(a[i] - a[i-1]), abs(a[i+1] - a[i])))
    
    for i in ans:
        print(i)

main()

Solution (Python):
N = int(input())
lsA = [0]+list(map(int,input().split()))+[0]
sum1 = 0
for i in range(1,N+2):
    sum1 += abs(lsA[i]-lsA[i-1])
lsans = []
for i in range(1,N+1):
    if lsA[i-1] <= lsA[i] and lsA[i] <= lsA[i+1]:
        lsans.append(sum1)
    elif lsA[i-1] >= lsA[i] and lsA[i] >= lsA[i+1]:
        lsans.append(sum1)
    else:
        div = min(abs(lsA[i-1]-lsA[i]),abs(lsA[i+1]-lsA[i]))
        lsans.append(sum1-2*div)
for i in lsans:
    print(i)

Solution (Python):


n = int(input())
a = list(map(int, input().split()))

a = [0] + a + [0]

diff = []
for i in range(1, len(a)):
    diff.append(abs(a[i-1]-a[i]))

ans = sum(diff)


for i in range(1, len(diff)):
    tmp = abs(a[i+1]-a[i-1])-abs(a[i]-a[i+1])-abs(a[i-1]-a[i])
    print(ans+tmp)

Solution (Python):
N = int(input())
A = [int(x) for x in input().split()]
A.insert(0,0)
A.append(0)
cost = 0
for i in range(1,N+2):
    cost += abs(A[i]-A[i-1])

def change(i):
    global A
    return -abs(A[i+1]-A[i])-abs(A[i]-A[i-1])+abs(A[i+1]-A[i-1])

for i in range(1,N+1):
    print(cost+change(i))

Solution (Python):
n=int(input())
a=[int(i) for i in input().split()]
a.append(0)
a=[0]+a
total=0

for i in range(1,n+2):
    total+=abs(a[i-1]-a[i])

def herasu(i):
    ans=total-abs(a[i-1]-a[i])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1])
    return ans


for i in range(1,n+1):
    print(herasu(i))

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
A = [0]+A+[0]
cum = [0]*(N+2)
for i in range(1, N+2):
    cum[i] = cum[i-1] + abs(A[i]-A[i-1])
for i in range(1, N+1):
    print(cum[N+1]-abs(A[i]-A[i-1])-abs(A[i]-A[i+1])+abs(A[i-1]-A[i+1]))

Solution (Python):
N = int(input())
A = [0]+list(map(int, input().split()))+[0]
res = 0
for i in range(1,N+2):
    res += abs(A[i]-A[i-1])
for i in range(1,N+1):
    print(res - abs(A[i+1]-A[i]) - abs(A[i]-A[i-1]) + abs(A[i+1]-A[i-1]))

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
A = [0] + A  
A.append(0)

cost = [0]*(N+1)
for i in range(0,N+1):
    cost[i] = abs(A[i+1] - A[i])
ini = sum(cost)

for i in range(1,N+1):  
    dam = ini
    dam -= cost[i-1]
    dam -= cost[i]
    dam += abs(A[i+1] - A[i-1])
    print(dam)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a = [0] + a + [0]

max_fee = 0
for i in range(1, n + 2):
    max_fee += abs(a[i] - a[i - 1])

for i in range(1, n + 1):
    if a[i - 1] <= a[i] <= a[i + 1] or a[i + 1] <= a[i] <= a[i - 1]:
        print(max_fee)
    else:
        res = max_fee - min(abs(a[i + 1] - a[i]) * 2, abs(a[i] - a[i - 1]) * 2)
        print(res)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a = [0] + a + [0]

max_fee = 0
for i in range(1, n + 2):
    max_fee += abs(a[i] - a[i - 1])

for i in range(1, n + 1):
    res = max_fee - abs(a[i] - a[i - 1]) - \
        abs(a[i + 1] - a[i]) + abs(a[i + 1] - a[i - 1])
    print(res)

Solution (Python):
def cost(i, j=1):
    return abs(a[i] - a[i+j])

n = int(input())
a = [0] + [int(i) for i in input().split()] + [0]

c = sum([cost(i) for i in range(n+1)])
for i in range(1, n+1):
    print(c - cost(i-1) - cost(i) + cost(i-1, 2))

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
a.append(0)
a.insert(0,0)
l=0
for i in range(n+1):
    l+=abs(a[i]-a[i+1])
for i in range(1,n+1):
    print(l-abs(a[i-1]-a[i])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1]))

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

d = [abs(a[0])]
for i in range(n-1):
    d.append(abs(a[i+1] - a[i]))

d.append(abs(a[-1]))

s = sum(d)

for i in range(n):
    if i == 0:
        t = s - d[i] - d[i+1] + abs(a[i+1])
    elif i == n-1:
        t = s - d[i] - d[i+1] + abs(-a[i-1])
    else:
        t = s - d[i] - d[i+1] + abs(a[i+1] - a[i-1])
    print(t)

Solution (Python):
n = int(input())
lst = list(map(int, input().split()))
lst.append(0)
lst.insert(0, 0)

dist = []
for i in range(n+1):
  dist.append(abs(lst[i+1]-lst[i]))

sum_dist = sum(dist)
for i in range(n):
  ans = sum_dist-(dist[i]+dist[i+1])
  ans += abs(lst[i]-lst[i+2])
  print(ans)

Solution (Python):
def main():
    N = int(input())
    A = [0]
    A += list(map(int, input().split()))
    A.append(0)
    total_dist = sum([abs(A[i+1] - A[i]) for i in range(N + 1)])
    for i in range(1, N + 1):
        print(total_dist - abs(A[i+1] - A[i]) - abs(A[i] - A[i-1]) + abs(A[i+1] - A[i-1]))


if __name__ == '__main__':
    main()

Solution (Python):
N=int(input())
A=[0]+list(map(int, input().split()))+[0]
s=sum(abs(A[i+1]-A[i]) for i in range(N+1))
for i in range(1,N+1):
  a=A[i-1]
  b=A[i]
  c=A[i+1]
  if b<a and b<c:
    ans=s-abs(b-min(a,c))*2
  elif b>a and b>c:
    ans=s-abs(b-max(a,c))*2
  else:
    ans=s
  print(ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
B = A[:]
B.insert(0, 0)
B.append(0)

sum = 0

for i in range(N+1):
  sum += abs(B[i+1] - B[i])
  
for i in range(N):
  
  x = abs(B[i+1] - B[i]) + abs(B[i+2] - B[i+1])
  
  y = abs(B[i+2] - B[i])
  print(sum - x + y)

Solution (Python):
n=int(input())
a=[0]+list(map(int,input().split()))+[0]
sum_a=0
for i in range(n+1):
  sum_a+=abs(a[i+1]-a[i])
for i in range(n):
  print(sum_a-abs(a[i+1]-a[i])-abs(a[i+2]-a[i+1])+abs(a[i+2]-a[i]))

Solution (Python):
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial

from functools import reduce
from pprint import pprint
from statistics import mean,median,mode

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]







n = I()
a = RI()

lc = []
for i in range(n):
    if i==0:
        c = abs( a[i] )
    else:
        c = abs( a[i] - a[i-1] )
    lc.append(c)

s = sum(lc)

for i in range(n):
    if i==0:
        ans = s - lc[i] - lc[i+1] + abs(a[1]) + abs(a[n-1])
    elif i==(n-1):
        ans = s - lc[i] + abs(a[n-2])
    else:
        ans = s - lc[i] - lc[i+1] + abs(a[i+1]-a[i-1]) + abs(a[n-1])
    print(ans)

Solution (Python):
n = int(input())
a = list(map(int,input().split())) + [0]
b = [abs(a[0])]+[abs(a[i+1]-a[i]) for i in range(n)]
c = [abs(a[1])]+[abs(a[i+2]-a[i]) for i in range(n-1)]

hon = sum(b)

for i in range(n):
    print(hon-b[i]-b[i+1]+c[i])

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a = [0] + a + [0]
tnp = 0
for i in range(1,n+2):
    tnp += abs(a[i]-a[i-1])
for i in range(n):
    ans = tnp - abs(a[i+1]-a[i]) - abs(a[i+2]-a[i+1]) + abs(a[i+2]-a[i])
    print(ans)

Solution (Python):
import copy
n = int(input())
a = [0] + list(map(int, input().split())) + [0]
cost = 0
for i in range(n+1):
    cost += abs(a[i]-a[i+1])
for i in range(1, n+1):
    ans = copy.deepcopy(cost)
    if a[i-1] <= a[i] and a[i+1] <= a[i]:
        ans -= 2*abs(a[i]-max(a[i-1], a[i+1]))
    elif a[i-1] >= a[i] and a[i+1] >= a[i]:
        ans -= 2*abs(a[i]-min(a[i-1], a[i+1]))
    print(ans)

Solution (Python):
N = int(input())
A = [0] + list(map(int,input().split())) + [0]
B = [0] * (N+1)
total = 0
for i in range(N+1):
    B[i] = A[i+1]-A[i]
    total += abs(B[i])
for i in range(N):
    print(total - (abs(B[i])+abs(B[i+1])) + abs(B[i]+B[i+1]))

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.append(0)
a.insert(0,0)
s = 0
for i in range(len(a)-1):
    s += abs(a[i]-a[i+1])
for h in range(1,n+1):
    t = abs(a[h+1]-a[h-1])-abs(a[h]-a[h-1])-abs(a[h+1]-a[h])
    print(s+t)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

A = [0] + A + [0]
sum_all = 0

for i, a in enumerate(A[1:N + 2], start=1):
    sum_all += abs(a - A[i - 1])

for i, a in enumerate(A[1:N + 1], start=1):
    print(sum_all - abs(a - A[i - 1]) - abs(a - A[i + 1]) + abs(A[i + 1] - A[i - 1]))

Solution (Python):
n = int(input())
a = [0] + [int(x) for x in input().split()] + [0]
diff = [abs(a[i] - a[i + 1]) for i in range(n + 1)]
tot = sum(diff)
for i in range(1, n + 1):
    print(tot - diff[i - 1] - diff[i] + abs(a[i - 1] - a[i + 1]))

Solution (Python):
n=int(input())
c=list(map(int, input().split()))
c = [0] + c + [0]
ans = 0

for i in range(n+1):
    ans += abs(c[i+1]-c[i])

for i in range(n):
    d = abs(c[i+1]-c[i])+ abs(c[i+2]-c[i+1])
    e = abs(c[i+2]-c[i])
    print(ans - d + e)

Solution (Python):


n = int(input())
a = list(map(int, input().split()))
a = [0] + a + [0] 

total = 0 
for i in range(n+1):
   total += abs(a[i]-a[i+1])

for i in range(1, n+1):
    ans = total-(abs(a[i]-a[i-1])+abs(a[i+1]-a[i]))+abs(a[i+1]-a[i-1])
    print(ans)

Solution (Python):
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())

A = [0] + list(map(int, input().split())) + [0]

S = 0
for i in range(N + 1):
    S += abs(A[i] - A[i + 1])

for i in range(N):
    print(S - abs(A[i] - A[i + 1]) - abs(A[i + 1] - A[i + 2]) + abs(A[i] - A[i + 2]))

Solution (Python):
n = int(input())
a = [0] + list(map(int, input().split())) + [0]

res = [0]*(n+1)
for i in range(n+1):
  res[i] = abs(a[i]-a[i+1])
  
t = sum(res)
for i in range(1, n+1):
  ans = t - (res[i-1]+res[i]) + abs(a[i-1]-a[i+1])
  print(ans)

Solution (Python):
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    A = nl()
    total = sum([abs(A[i + 1] - A[i]) for i in range(n - 1)])
    for i in range(n):
        if i == 0:
            start = abs(A[1])
            end = abs(A[-1])
            print(total - abs(A[1] - A[0]) + start + end)
        elif i == n - 1:
            start = abs(A[0])
            end = abs(A[-2])
            print(total - abs(A[-2] - A[-1]) + start + end)
        else:
            start = abs(A[0])
            end = abs(A[-1])
            print(total - abs(A[i - 1] - A[i]) -
                  abs(A[i] - A[i + 1]) + abs(A[i + 1] - A[i - 1])
                  + start + end)


if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
a=[0]+list(map(int,input().split()))+[0]

dist=[]

for i in range(len(a)-1):
  dist.append(abs(a[i+1]-a[i]))
  
xxx=sum(dist)

for i in range(n):
  ans=xxx
  ans-=dist[i]
  ans-=dist[i+1]
  ans+=abs(a[i+2]-a[i])
  print(ans)

Solution (Python):
input()
a = [0] + list(map(int, input().split())) + [0]
a = [j - i for i, j in zip(a, a[1:])]
x = sum(abs(i) for i in a)
for i, j in zip(a, a[1:]):
    if i * j >= 0:
        print(x)
    else:
        print(x - 2 * (min(abs(i), abs(j))))

Solution (Python):
n = int(input())
a = [0]+list(map(int, input().split()))+[0]

nums = [0]*(n+1)
for i in range(n+1): nums[i] = abs(a[i]-a[i+1])

t = sum(nums)
for i in range(1,n+1):
  ans = t - (nums[i-1]+nums[i]) + abs(a[i-1]-a[i+1])
  print(ans)

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    B = [0]
    B.extend(A)
    B.append(0)

    M = len(B)

    total = 0
    for i in range(M - 1):
        total += abs(B[i + 1] - B[i])

    ans = [0] * N
    for i in range(N):
        ans[i] = total - abs(B[i + 1] - B[i]) - abs(B[i + 2] - B[i + 1]) + abs(B[i + 2] - B[i])

    print(*ans, sep='\n')
    return


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
A = [0] + a + [0]

total_fee = 0
for i in range(N+1):
    total_fee += abs(A[i+1]-A[i])

ans_lst = [total_fee] * N
for j in range(N):
    ans_lst[j] -= abs(A[j+1]-A[j])
    ans_lst[j] -= abs(A[j+2]-A[j+1])
    ans_lst[j] += abs(A[j+2]-A[j])
    print(ans_lst[j])

Solution (Python):
n=int(input())
a=list(map(int,input().split()))

sum1=0
for x in range(n-1):
  sum1+=abs(a[x]-a[x+1])
  
sum1+=abs(a[0])+abs(a[n-1])
for y in range(n):
  if y==0:
    print(sum1-abs(a[0])-abs(a[1]-a[0])+abs(a[1]))
  elif y==n-1:
    print(sum1-abs(a[n-1]-a[n-2])-abs(a[n-1])+abs(a[n-2]))
  else:
    print(sum1-abs(a[y]-a[y-1])-abs(a[y]-a[y+1])+abs(a[y-1]-a[y+1]))

Solution (Python):
def main():
    n = int(input())
    inlis = list(map(int, input().split()))

    total = 0
    mae = 0

    for i in range(n):
        total += abs(inlis[i] - mae)
        mae = inlis[i]
    total += abs(inlis[-1])
    inlis.append(0)

    
    if 0 <= inlis[0] and inlis[0] > inlis[1]:
        if inlis[1] >0:
            print(total - 2 * abs(inlis[1] - inlis[0]))
        else:
            print(total - 2 * abs(inlis[0]))
    elif 0 >= inlis[0] and inlis[0]< inlis[1]:
        if inlis[1] < 0:
            print(total - 2 * abs(inlis[1] - inlis[0]))
        else:
            print(total - 2 * abs(inlis[0]))
    else:
        print(total)

    for j in range(1, n):
        if inlis[j-1] <= inlis[j] <= inlis[j+1] or inlis[j-1]>= inlis[j] >= inlis[j+1]:
            print(total)
        elif inlis[j-1] <= inlis[j] and inlis[j] > inlis[j+1]:
            if inlis[j-1] >= inlis[j+1]:
                print(total - 2 * abs(inlis[j-1] - inlis[j]))
            else:
                print(total- 2 * abs(inlis[j+1] - inlis[j]))
        elif inlis[j-1]>= inlis[j] and inlis[j] < inlis[j+1]:
            if inlis[j-1] >= inlis[j+1]:
                print(total - 2 * abs(inlis[j+1] - inlis[j]))
            else:
                print(total - 2 * abs(inlis[j-1] - inlis[j]))
    



        


if __name__ == "__main__":
    main()

Solution (Python):
n=int(input())
a=[0]+list(map(int,input().split()))+[0]
b=[]
for i in range(n+1):
    b.append(abs(a[i+1]-a[i]))
temp=sum(b)

for j in range(n):
    ans=temp-b[j]-b[j+1]+abs(a[j+2]-a[j])
    print(ans)

Solution (Python):
import numpy as np

N=int(input())
A=np.array(list(map(int,input().split())))
A=np.append(A,0)
A=np.insert(A,0,0)
S=sum(abs(np.diff(A[:])))

for i in range(1,len(A)-1):
  if A[i-1]==A[i]:
    print(S)
  elif (A[i-1]<A[i] and A[i]<A[i+1]) or (A[i-1]>A[i] and A[i]>A[i+1]):
    print(S)
  else:
    print(S-min(abs(A[i-1]-A[i]),abs(A[i]-A[i+1]))*2)

Solution (Python):
N = int(input())
X = list(map(int, input().split()))
X.append(0)
load = 0
now = 0
for i in range(N + 1):
  load += abs(X[i] - now)
  now = X[i]
  


now = 0
for i in range(N):
  if now <= X[i] <= X[i + 1]:
    print(load)
  elif X[i + 1] <= X[i] <= now:
    print(load)
  else:
    ll = 2 * min(abs(X[i] - now), abs(X[i] - X[i + 1]))
    print(load - ll)
  now = X[i]

Solution (Python):
N=int(input())
A=list(map(int,input().split()))

SUM=abs(A[0])
for i in range(N):
  if i < N-1:
    SUM += abs(A[i+1]-A[i])
  else:
    SUM += abs(0-A[i])

now=0
for i in range(N):
  if i != N-1:
    diff = abs(A[i+1]-now)-abs(A[i]-now)-abs(A[i+1]-A[i])
    now = A[i]
  else:
    diff = abs(0-now)-abs(A[i]-now)-abs(0-A[i])
  print(SUM + diff)

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
m=[abs(0-A[0])]*(N+1)
for i in range(1,N):
    m[i]=abs(A[i]-A[i-1])
m[-1]=abs(0-A[-1])
a=sum(m)
A.append(0)
for i in range(N):
    print(a+abs(A[i-1]-A[i+1])-(abs(A[i-1]-A[i])+abs(A[i]-A[i+1])))

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

cost = abs(A[0])
for i in range(1, N):
    cost += abs(A[i] - A[i - 1])
cost += abs(A[N - 1])

prev = 0
A.append(0)
for i in range(N):
    x = abs(A[i + 1] - prev)
    y = abs(A[i] - prev) + abs(A[i + 1] - A[i])
    print(cost - (y - x))
    prev = A[i]

Solution (Python):
n,ais,cumul,res =int(raw_input()),[0] + map(int,raw_input().split()) + [0],0,[]
for i in range(1,len(ais)):
	if i < len(ais) -1: res.append(-abs(ais[i] - ais[i-1]) - abs(ais[i+1] - ais[i]) + abs(ais[i+1] - ais[i-1]))
	cumul += abs(ais[i] - ais[i-1])
for v in res: print v + cumul

Solution (Python):
n = int(raw_input())
ais =[0] + map(int,raw_input().split()) + [0]
skip = -float('inf')
cumul = 0
res  = []
for i in range(1,len(ais)-1):
	val = abs(ais[i] - ais[i-1])
	skip = -abs(ais[i] - ais[i-1]) - abs(ais[i+1] - ais[i]) + abs(ais[i+1] - ais[i-1])
	res.append(skip)
	cumul += val
cumul += abs(ais[-1] - ais[-2])
for i in range(len(res)):
	print res[i] + cumul

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

total = 0
for i in range(1,n):
    total += abs(a[i] - a[i-1])

total +=  abs(a[0]) + abs(a[-1])

a.insert(0, 0)
a.append(0)
for i in range(1,n+1):
    if a[i-1] <= a[i] and a[i] <= a[i+1]:
        print(total)
    elif a[i+1] <= a[i] and a[i] <= a[i-1]:
        print(total)
    elif max(a[i-1], a[i+1]) < a[i]:
        print(total - abs(a[i] - max(a[i-1], a[i+1]))*2)
    elif a[i] < min(a[i-1], a[i+1]):
        print(total - abs(a[i] - min(a[i-1], a[i+1]))*2)

Solution (Python):
n = int(input())
A = [0] + list(map(int, input().split())) + [0]

cost = 0
for i in range(n+1):
    cost += abs(A[i] - A[i+1])

for i in range(1, n+1):
    ans = cost
    ans -= abs(A[i] - A[i-1])
    ans -= abs(A[i] - A[i+1])
    ans += abs(A[i-1] - A[i+1])
    print(ans)

Solution (Python):
n = int(input())

a = [int(i) for i in input().split()]
a.append(0)
a.insert(0,0)

cost =0
for i in range(1,len(a)):
    cost += abs(a[i-1] - a[i])

for i in range(1,len(a)-1):
    if a[i-1] < a[i] < a[i+1]:
        ans = cost
    elif a[i-1] > a[i] > a[i+1]:
        ans = cost
    else:
        ans = cost - abs(a[i-1] - a[i]) - abs(a[i] - a[i+1]) + abs(a[i-1] - a[i+1])
    print(ans)

Solution (Python):
N=int(input())+2
A=[0]
A.extend(list(map(int,input().split())))
A.append(0)
B=sum(abs(A[i]-A[i-1]) for i in range(1,N))
for i in range(1,N-1):
  print(B-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1]))