CodeEff/ECCO huggingface dataset:
# Original solution
n = int(eval(input()))
s = list(map(int,input().split()))
sum = 0
s.insert(0, 0)
s.insert(n+1, 0)
for i in range(1,n+1):
    st = s[i]
    s.pop(i)
    for j in range(n):
        sum += abs((s[j])-(s[j+1]))
    print(sum)
    s.insert(i, st)
    sum = 0

# Optimized solution
n = int(eval(input()))
s = list(map(int,input().split()))
sum = 0
s.insert(0, 0)
s.insert(n+1, 0)
for i in range(n+1):
    sum += abs((s[i])-(s[i+1]))
for j in range(1,n+1):
    print((sum - abs(s[j-1]-s[j]) - abs(s[j]-s[j+1]) +abs(s[j-1]-s[j+1])))
# Original solution
n=int(eval(input()))
a=[0]+list(map(int,input().split()))+[0]
anew=[]
for i in range(n+1):
    anew.append(abs(a[i]-a[i+1]))
for j in range(1,n+1):
    ans=sum(anew)-anew[j-1]-anew[j]+abs(a[j-1]-a[j+1])
    print(ans)

# Optimized solution
n=int(eval(input()))
a=[0]+list(map(int,input().split()))+[0]
s=sum(abs(a[i]-a[i+1]) for i in range(len(a)-1))
for i in range(1,n+1):
    print((s-abs(a[i]-a[i+1])-abs(a[i]-a[i-1])+abs(a[i-1]-a[i+1])))
# Original solution
N = int(eval(input()))
a = list(map(int, input().split()))
a.insert(0, 0)
a.append(0)
# print(a)

# iは除く番号
for i in range(1, N + 1):
  s = 0
  for j in range(N + 1):
    if j + 1 == i:
      s += abs(a[j] - a[j+2])
    elif j != i:
      s += abs(a[j] - a[j+1])      
  print(s)

# Optimized solution
N = int(eval(input()))
a = list(map(int, input().split()))
a.insert(0, 0)
a.append(0)
# print(a)

li = [abs(a[i] - a[i+1]) for i in range(N + 1)]
sumli = sum(li)

# iは除く番号
for i in range(1, N + 1):
  print((sumli - (li[i-1] + li[i]) + abs(a[i-1]-a[i+1])))
# Original solution
import copy
nu = int(eval(input()))
data = list(map(int,input().split()))
al = 0
for i in range(nu):
  ta = copy.deepcopy(data)
  da = ta.pop(i)
  for j in range(nu - 2):
    al += abs(ta[j + 1] - ta[j])
  if i == 0:
    al += abs(data[1]) + abs(data[nu - 1])
  elif i == nu - 1:
    al += abs(data[0]) + abs(data[nu - 2])
  else:
    al += abs(data[0]) + abs(data[nu - 1])
  print(al)
  al = 0



# Optimized solution
n = int(eval(input()))

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

su = 0
su += abs(a[0])
for i in range(n-1):
    su += abs(a[i+1] - a[i])
su += abs(a[-1])
for i in range(n):
    if i == 0:
        print((su - abs(a[0]) - abs(a[0] - a[1])+ abs(a[1])))
    elif i == n-1:
        print((su - abs(a[-1]) - abs(a[-1] - a[-2]) + abs(a[-2])))
    else:
        print((su - abs(a[i] - a[i-1]) - abs(a[i] - a[i+1]) + abs(a[i+1] - a[i-1])))
# Original solution
import difflib
n = int(eval(input()))
l = list(map(int, input().split()))
total = 0
last = 0
for i in range(n):
  total = 0
  last = 0
  for j in range(n):
    if j == i:
      pass
    else:
      total += abs(l[j] - last)
      last = l[j]
  total += abs(last)
  print(total)

# Optimized solution
n = int(eval(input()))
l = [0]
l += list(map(int, input().split()))
l += [0]
base = 0

for i in range(n+2):
  base += abs(l[i-1] - l[i])

for i in range(1, n+1):
  ans = base + abs(l[i+1]-l[i-1]) - abs(l[i+1]-l[i]) - abs(l[i-1]-l[i])
  print(ans)
# Original solution
N=int(eval(input()))
A=list(map(int,input().split()))

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

for i in range(N):
  total=sum(cost)+abs(A[0])+abs(A[N-1])
  if i == 0:
    total-=abs(A[i])
    total-=cost[i]
    total+=abs(A[i+1])
  elif i == N-1:
    total-=abs(A[i])
    total+=abs(A[i-1])
    total-=cost[i-1]
  else:
    total-=cost[i]
    total-=cost[i-1]
    total+=abs(A[i+1]-A[i-1])
  print(total)

# Optimized solution
N=int(eval(input()))
A=list(map(int,input().split()))

cost=[abs(A[i]-A[i+1]) for i in range(N-1)]
costsum=total=sum(cost)+abs(A[0])+abs(A[N-1])
for i in range(N):
  total=costsum
  if i == 0:
    total-=abs(A[i])
    total-=cost[i]
    total+=abs(A[i+1])
  elif i == N-1:
    total-=abs(A[i])
    total+=abs(A[i-1])
    total-=cost[i-1]
  else:
    total-=cost[i]
    total-=cost[i-1]
    total+=abs(A[i+1]-A[i-1])
  print(total)
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))
for i in range(n):
    ans,x=0,0
    for j in range(n):
        if j==i: continue
        ans+=abs(x-a[j])
        x=a[j]
    print((ans+abs(x)))

# Optimized solution
n=int(eval(input()))
a=list(map(int,input().split()))
x,m=0,0
for i in range(n):
    m+=abs(x-a[i])
    x=a[i]
m+=abs(x)
for i in range(n):
    ans=m
    if i==0: ans+=abs(a[i+1])-abs(a[i+1]-a[i])-abs(a[i])
    elif i==n-1:
        ans+=abs(a[i-1])-abs(a[i])-abs(a[i]-a[i-1])
    else:
        ans+=abs(a[i+1]-a[i-1])-abs(a[i]-a[i-1])-abs(a[i]-a[i+1])
    print(ans)
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))

for i in range(n):
    b = [0] + a[:i] + a[i+1:] + [0]
    ans = 0
    for j in range(len(b)-1):
        ans += abs(b[j] - b[j+1])
    print(ans)

# Optimized solution
n = int(eval(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 j in range(1, n+1):
    if a[j-1] <= a[j] <= a[j+1] or a[j-1] >= a[j] >= a[j+1]:
        print(cost)
    else:
        print((cost - min(abs(a[j] - a[j-1]), abs(a[j] - a[j+1]))*2))
# Original solution
N = int(eval(input()))
A = [0] + list(map(int, input().split())) + [0]
for idx in range(1, N+1):
    i = 0
    tmp = 0
    while i < len(A)-1:
        if idx == i+1:
            tmp += abs(A[i]-A[i+2])
            i += 2
        else:
            tmp += abs(A[i]-A[i+1])
            i += 1
    print(tmp)


# Optimized solution
N = int(eval(input()))
A = [0] + list(map(int, input().split())) + [0]
S = sum(abs(A[i]-A[i+1]) for i in range(len(A)-1))
for i in range(1, N+1):
    print((S-(abs(A[i]-A[i+1]) + abs(A[i]-A[i-1]))+abs(A[i+1]-A[i-1])))
# Original solution
n = int(eval(input()))
spotStrList = input().split()
result = 0
spotList = ['0']
for x in range(n):
    spotList.append(spotStrList[x])
spotList.append('0')

def travelfrom(spotNum, skipNum):
    if spotNum == skipNum:
        return 0
    elif spotNum == skipNum -1:
        return abs(int(spotList[spotNum+2])-int(spotList[spotNum]))
    else:
        return abs(int(spotList[spotNum+1])-int(spotList[spotNum]))
              
for i in range(n):
    for spot in range(n+1):
        result += travelfrom(spot,i+1)
    print(result)
    result=0

# Optimized solution
distanceSum = 0
spotCount = int(eval(input()))
spotList = input().split()
spotList = [int(i) for i in spotList]
spotList.append(0)

def calcDistance(num): # 配列num-1番のスポットから配列num番目のスポットへの距離を計算
    if num == 0: #開始地点から配列0番＝最初のスポット
        return abs(spotList[num])
    elif num == spotCount: #最後スポットから開始地点
        return abs(spotList[num-1])
    else:
        return abs(spotList[num]-spotList[num-1])

def calcSkipEffect(num): #配列num番をスキップした時の移動距離への影響を計算
    if num == 0: #最初のスポットの時だけの例外
        return abs(spotList[num+1])-abs(spotList[num])-abs(spotList[num+1]-spotList[num])
    else:
        return abs(spotList[num+1]-spotList[num-1])-abs(spotList[num]-spotList[num-1])-abs(spotList[num+1]-spotList[num])

for i in range(spotCount+1): #総移動回数はスポット数+1
    distanceSum += calcDistance(i)
    
for j in range(spotCount): #配列0～n-1番までの各スポットについて実行
    print((str(distanceSum + calcSkipEffect(j))))
# Original solution
N = int(eval(input()))
A = list(map(int, input().strip().split()))
A = [0] + A + [0]

Diff = [abs(A[i]-A[i+1]) for i in range(N+1) ]

for j in range(N):
        print((sum(Diff)-sum(Diff[j:j+2])+abs(A[j]-A[j+2])))

# Optimized solution
N = int(input().strip())
A = list(map(int,input().strip().split(' ')))
B = [0]+A+[0]
sums=0
for i in range(N+1):
    sums = sums+abs(B[i]-B[i+1])

for i in range(1,N+1):
    if min(B[i-1],B[i+1]) <= B[i] and B[i] <= max(B[i-1],B[i+1]):
        print(sums)
    else:
        print((sums-2*min(abs(B[i]-B[i-1]),abs(B[i]-B[i+1]))))
# Original solution
import copy

def funcabs(a,b):
    if a>=b: ret = a-b
    else: ret = b-a
    return ret

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

for i in range(1,N+1):
    ans = 0
    B = copy.deepcopy(A)
    del B[i]
    for j in range(1,N+1):
        ans += funcabs(B[j],B[j-1])
    print(ans)

# Optimized solution
N = int(eval(input()))
A = list(map(int,input().split()))
A.insert(0,0)
A.append(0)

S = 0
for i in range(len(A)-1):
    S+=abs(A[i+1]-A[i])
    
for i in range(1,N+1):
    ans = S + abs(A[i+1]-A[i-1]) - abs(A[i+1]-A[i]) - abs(A[i]-A[i-1])
    print(ans)
# Original solution
def cost_culc(spot_list):
    cost = 0
    for i in range(1,len(spot_list)):
        cost += abs(spot_list[i]-spot_list[i-1])
    cost += abs(spot_list[0])+abs(spot_list[len(spot_list)-1])
    return cost

n = int(eval(input()))
spot_list = list(map(int,input().split()))

for i in range(len(spot_list)):
    deleted_list = spot_list[:i]+spot_list[i+1:]
    cost = cost_culc(deleted_list)
    print(cost)


# Optimized solution

n = int(eval(input()))
spot_list = list(map(int,input().split()))
max_cost = 0

#maxの計算
for i in range(1,len(spot_list)):
    max_cost += abs(spot_list[i]-spot_list[i-1])
max_cost += abs(spot_list[0])+abs(spot_list[len(spot_list)-1])

spot_list = [0] + spot_list + [0]
for i in range(1,len(spot_list)-1):
    d_pay = abs(spot_list[i-1]-spot_list[i+1]) - (abs(spot_list[i]-spot_list[i-1])+abs(spot_list[i+1]-spot_list[i]))
    print((max_cost+d_pay))
# Original solution
def main():
    N = int(eval(input()))
    *A, = list(map(int, input().split()))

    f(N, A)


def f(N, A):
    """
    2 ≤ N ≤ 10^5
    −5000 ≤ Ai ≤ 5000 (1≤ i≤ N)

    第一印象: 累積和?
    """
    costs = [abs(A[0])]
    costs_cumsum = [abs(A[0])]
    for i in range(1, N):
        cost = abs(A[i] - A[i-1])
        cumsum = cost + costs_cumsum[-1]

        costs.append(cost)
        costs_cumsum.append(cumsum)

    # 0へ戻る
    cost_N_to_start = abs(A[-1])
    costs.append(cost_N_to_start)
    costs_cumsum.append(cost_N_to_start + costs_cumsum[-1])

    for i in range(N):
        total = costs_cumsum[-1]
        # skip: i-1 to i and i to i+1
        total -= (costs[i] + costs[i+1])

        # add: i-1 to i+1
        bef, aft = 0, 0
        if i - 1 >= 0:
            bef = A[i-1]
        if i + 1 < N:
            aft = A[i+1]
        total += abs(bef - aft)

        print(total)


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    N = int(eval(input()))
    *A, = list(map(int, input().split()))

    f(N, A)


def f(N, A):
    """
    2 ≤ N ≤ 10^5
    −5000 ≤ Ai ≤ 5000 (1≤ i≤ N)

    第一印象: 累積和?
    →不要,合計のみ必要だった
    """
    costs = [abs(A[0])]
    for i in range(1, N):
        cost = abs(A[i] - A[i-1])
        costs.append(cost)

    # 0へ戻る
    cost_N_to_start = abs(A[-1])
    costs.append(cost_N_to_start)
    costs_cumsum = sum(costs)

    for i in range(N):
        total = costs_cumsum
        # skip: i-1 to i and i to i+1
        total -= (costs[i] + costs[i+1])

        # add: i-1 to i+1
        bef, aft = 0, 0
        if i - 1 >= 0:
            bef = A[i-1]
        if i + 1 < N:
            aft = A[i+1]
        total += abs(bef - aft)

        print(total)


if __name__ == '__main__':
    main()
# Original solution
N = int(eval(input()))
A = [int(a) for a in input().split()]
A.insert(0, 0)
A.append(0)

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

for j in range(1, N+1):
  M1 = sum(B_abs[:j-1])
  M2 = abs(B[j-1] + B[j])
  M3 = sum(B_abs[j+1:])
  M = M1 + M2 + M3
  print(M)

# Optimized solution
N = int(eval(input()))
A = [int(a) for a in input().split()]
A.insert(0, 0)
A.append(0)

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

B_abs = [abs(b) for b in B]
B_abs_cusum = [0]
cusum = 0
for j in B_abs:
  cusum += j
  B_abs_cusum.append(cusum)

for k in range(1, N+1):
  M1 = B_abs_cusum[k-1]
  M2 = abs(B[k-1] + B[k])
  M3 = B_abs_cusum[-1] - B_abs_cusum[k+1]
  M = M1 + M2 + M3
  print(M)
# Original solution
N = int(eval(input()))
A = [int(a) for a in input().split()]
A.insert(0, 0)
A.append(0)

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

B_abs = [abs(b) for b in B]
B_abs_cusum = [0]
cusum = 0
for j in B_abs:
  cusum += j
  B_abs_cusum.append(cusum)

for k in range(1, N+1):
  M1 = B_abs_cusum[k-1]
  M2 = abs(B[k-1] + B[k])
  M3 = B_abs_cusum[-1] - B_abs_cusum[k+1]
  M = M1 + M2 + M3
  print(M)

# Optimized solution
#YouTube解説
N = int(eval(input()))
A = [int(a) for a in input().split()]
A.insert(0, 0)
A.append(0)

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

for j in range(1, N+1):
  ans = 0
  A_im1 = A[j-1]
  A_i = A[j]
  A_ip1 = A[j+1]
  ans = total_money - abs(A_im1 - A_i) - abs(A_i - A_ip1) + abs(A_im1 - A_ip1)
  print(ans)
# Original solution
N = int(eval(input()))
A = [0] + list(map(int,input().split())) + [0]
dis = 0
for i in range(1, N+2):
  dis += abs(A[i]-A[i-1])
for i in range(1, N+1):
  print((dis - abs(A[i] - A[i-1]) - abs(A[i+1] - A[i]) + abs(A[i+1]-A[i-1])))


# Optimized solution
N = int(eval(input()))
A = [0]+list(map(int,input().split()))+[0]

maxMoney = sum([abs(A[i+1]-A[i]) for i in range(N+1)])
for i in range(1,N+1):
  print((maxMoney-abs(A[i-1]-A[i])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1])))
# Original solution
import copy

def calc_fee(l):
    s = 0
    l = [0] + l + [0]
    for i in range(len(l)-1):
        s += abs(l[i+1] - l[i])
    return s

n = int(eval(input()))
A = [int(n) for n in input().split()]

for i in range(n):
    A_ = copy.copy(A)
    del A_[i]
    
    price = calc_fee(A_)
    print(price)

# Optimized solution
def calc_fee(l):
    s = 0
    for i in range(len(l)-1):
        s += abs(l[i+1] - l[i])
    return s

n = int(eval(input()))
A = [0] + [int(n) for n in input().split()] + [0]


total_fee = calc_fee(A)

for i in range(1, n+1):
    price = total_fee - (abs(A[i] - A[i-1]) + abs(A[i+1] - A[i]))  + abs(A[i+1] - A[i-1])
    print(price)
# Original solution
import copy
n=int(eval(input()))
box=list(map(int,input().split()))
for i in range(n):
    box_ano=copy.copy(box)
    del box_ano[i]
    count=abs(box_ano[0])+abs(box_ano[-1])
    for j in range(len(box_ano)):
        try:
            count +=abs(box_ano[j]-box_ano[j+1])
        except:continue
    print(count)

# Optimized solution
import copy
n=int(eval(input()))
box=list(map(int,input().split()))
box.insert(0,0)
box.append(0)
count=0
for i in range(n+1):count +=abs(box[i]-box[i+1])
for j in range(1,n+1):
    print((count-(abs(box[j-1]-box[j])+abs(box[j]-box[j+1]))+abs(box[j-1]-box[j+1])))
# Original solution
n=int(eval(input()))
box=[0]+list(map(int,input().split()))+[0]
count=0
for i in range(n+1):count +=abs(box[i]-box[i+1])
for j in range(1,n+1):
    print((count-(abs(box[j-1]-box[j])+abs(box[j]-box[j+1]))+abs(box[j-1]-box[j+1])))

# Optimized solution
n=int(eval(input()))
add=list(map(int,input().split()))
add.insert(0,0)
add.append(0)
count=0
for i in range(n+1):
    count +=abs(add[i]-add[i+1])
for i in range(1,n+1):
    print((count-(abs(add[i-1]-add[i])+abs(add[i]-add[i+1]))+(abs(add[i-1]-add[i+1]))))
# Original solution
import copy
n = int(eval(input()))
a = list(map(int, input().split()))

for i in range(n):
    ans = 0
    a_i = a.copy()
    a_i.pop(i)
    for j in range(n-2):
        ans += abs(a_i[j+1] - a_i[j])
    ans += abs(a_i[0])
    ans += abs(a_i[-1])
    

    print(ans)





# Optimized solution
n = int(eval(input()))

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

s = 0



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

for i in range(1,n+1):
    if (a[i] - a[i-1])*(a[i+1] - a[i]) < 0:
        if abs(a[i] - a[i-1]) < abs(a[i+1] - a[i]):
            print((s - 2*abs(a[i] - a[i-1])))
        else:
            print((s - 2*abs(a[i+1] - a[i])))
    else :
        print(s)
# Original solution
#!python
# -*- coding: utf-8 -*-

N = int(eval(input()))
A = list(map(int, input().split(' ')))

a = 0
I = []
for b in A + [0]:
    I.append(b - a)
    a = b
S = sum(map(abs, I))

for i in range(N):
    j = i + 1
    A_ = [0] + A + [0]
    if A_[j - 1] <= A_[j] <= A_[j + 1]:
        print(S)
    else:
        I_ = I[:]
        I_[i] = I_[i] + I_[i + 1]
        del I_[i + 1]
        n = sum(map(abs, I_))
        print(n)


# Optimized solution
#!python
# -*- coding: utf-8 -*-

N = int(eval(input()))
A = list(map(int, input().split(' ')))

a = 0
I = []
for b in A + [0]:
    I.append(b - a)
    a = b
S = sum(map(abs, I))

for i in range(N):
    j = i + 1
    n = S - (abs(I[i]) + abs(I[i + 1])) + abs(I[i] + I[i + 1])
    print(n)
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))

for i in range(n):
    x = a.pop(i)
    ans, c = 0, 0
    for j in a:
        ans += abs(c-j)
        c = j
    a.insert(i, x)
    ans += abs(c-0)
    print(ans)


# Optimized solution
n = int(eval(input()))
a = [0] + list(map(int, input().split())) + [0]
s = sum([abs(a[i]-a[i-1]) for i in range(1, n+2)])
for i in range(1, n+1):
    x = abs(a[i]-a[i-1])
    y = abs(a[i+1]-a[i])
    z = abs(a[i+1]-a[i-1])
    print((s-x-y+z))
# Original solution
N = int(eval(input()))
a = list(map(int, input().split()))

ans = []

for i in range(N):
    temp=0
    if i == 0:
        for j in range(N):
            if j == 0:
                temp += abs(a[1])
            elif j != N-1:
                temp += abs(a[j+1] - a[j])
            else:
                temp += abs(a[j])
    elif i != N-1:
        for j in range(N):
            if j == 0:
                temp += abs(a[0])
            elif j < i:
                temp += abs(a[j]-a[j-1])
            elif j == i:
                temp += abs(a[j+1]-a[j-1])
            elif (j > i) and (j < N-1):
                temp += abs(a[j+1]-a[j])
            else:
                temp += abs(a[j])
    else:
        for j in range(N):
            if j == 0:
                temp += abs(a[0])
            elif j != N-1:
                temp += abs(a[j]-a[j-1])
            else:
                temp += abs(a[j-1])
    ans.append(temp)
      
for x in range(N):
    print((ans[x]))

# Optimized solution
N = int(eval(input()))
a = list(map(int, input().split()))

ans = []

s = 0
for i in range(N):
    if i == 0:
        s += abs(a[0])
    else:
        s += abs(a[i]-a[i-1])
s += abs(a[-1])

for i in range(N):
    if i == 0:
        temp = s  - abs(a[i]) - abs(a[i+1]-a[i]) + abs(a[i+1])
    elif i < N-1:
        temp = s - abs(a[i]-a[i-1]) - abs(a[i+1]-a[i]) + abs(a[i+1]-a[i-1])
    else:
        temp = s - abs(a[i]) - abs(a[i]-a[i-1]) + abs(a[i-1])
    ans.append(temp)
for x in range(N):
    print((ans[x]))
# Original solution
def c_traveling_plan(N, A):
    total = 0  # すべての観光スポットを順に回ったときの費用
    a = [0] + A + [0]  # 0から出発して最後に0に帰るためこうする(forループも楽)
    for i in range(N + 1):
        total += abs(a[i] - a[i + 1])
    ans = ''
    for i in range(1, N + 1):
        # a_{i-1}->a_i->a_{i+1} をつなぐ2つの経路の長さ(delta1)を引き、
        # 新しい経路の長さ(delta2)を足す
        delta1 = abs(a[i - 1] - a[i]) + abs(a[i] - a[i + 1])
        delta2 = abs(a[i - 1] - a[i + 1])
        ans += '{0}\n'.format(total - delta1 + delta2)
    return ans[:-1]
  
N = int(eval(input()))
A = [int(i) for i in input().split()]
print((c_traveling_plan(N, A)))

# Optimized solution
def c_traveling_plan():
    N = int(eval(input()))
    # 原点から出発して最後に原点に帰るためこうする (forループも楽)
    A = [0] + [int(i) for i in input().split()] + [0]

    total_tour_cost = sum([abs(A[i] - A[i + 1]) for i in range(N + 1)])
    ans = []
    for i in range(1, N + 1):
        # a_{i-1} -> a_i -> a_{i+1} の長さ(delta1)を引き，
        # a_{i-1} -> a_{i+1} の長さ(delta2)を足す
        delta1 = abs(A[i - 1] - A[i]) + abs(A[i] - A[i + 1])
        delta2 = abs(A[i - 1] - A[i + 1])
        ans.append(total_tour_cost - delta1 + delta2)
    return '\n'.join(map(str, ans))

print((c_traveling_plan()))
# Original solution
n=int(eval(input()))
A=[int(i) for i in input().split()]
A.append(0)
D=[abs(A[0])]
for i in range(n-1):
  D+=[abs(A[i]-A[i+1])]
D.append(abs(A[n-1]))
for i in range(n):
  print((sum(D[:i])+abs(A[i-1]-A[i+1])+sum(D[i+2:])))

# Optimized solution
n=int(eval(input()))
A=[int(i) for i in input().split()]
A.append(0)
D=[abs(A[0])]
for i in range(n-1):
  D+=[abs(A[i]-A[i+1])]
D.append(abs(A[n-1]))
d=sum(D)
for i in range(n):
  print((d+abs(A[i-1]-A[i+1])-D[i]-D[i+1]))
# Original solution
n=int(eval(input()))
a=[0]+[int(i) for i in input().split()]+[0]
cost=[abs(a[i+1]-a[i]) for i in range(n+1)]
#print(cost)
for i in range(n):
    Cost=cost[:i]+cost[i+2:]+[abs(a[i+2]-a[i])]
    #print(Cost)
    print((sum(Cost)))



# Optimized solution
n=int(eval(input()))
a=[0]+[int(i) for i in input().split()]+[0]
cost=[abs(a[i+1]-a[i]) for i in range(n+1)]
C=sum(cost)
#print(cost)
for i in range(1,n+1):
    Co=C-(abs(a[i+1]-a[i]))-abs((a[i]-a[i-1]))+abs(a[i+1]-a[i-1])
    print(Co)
# Original solution
# Traveling Plan
n = int(eval(input()))
a = [0]
a += list(map(int, input().split()))
a += [0]
for i in range(n):
    ans = 0
    for j in range(n+1):
        if j == i:
            ans += abs(a[j]-a[j+2])
        elif j == i+1:
            pass
        else:
            ans += abs(a[j]-a[j+1])
    print(ans)


# Optimized solution
# Traveling Plan
n = int(eval(input()))
a = [0]
a += list(map(int, input().split()))
a += [0]
total = 0
for i in range(n+1):
    total += abs(a[i]-a[i+1])
for i in range(n):
    p = total -(abs(a[i]-a[i+1]) + abs(a[i+1]-a[i+2])) + abs(a[i]-a[i+2])
    print(p)
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))
base=0
for i in range(n+1):
    if i==0:
        base+=abs(a[0])
    elif i==n:
        base+=abs(a[n-1])
    else:
        base+=abs(a[i]-a[i-1])
ans=[]
for i in range(n):
    if i==0:
        ans.append(base+abs(a[1])-abs(a[0])-abs(a[1]-a[0]))
    elif i==n-1:
        ans.append(base+abs(a[n-2])-abs(a[n-1])-abs(a[n-2]-a[n-1]))
    else:
        ans.append(base+abs(a[i+1]-a[i-1])-abs(a[i+1]-a[i])-abs(a[i]-a[i-1]))
for i in range(n):
    print((ans[i]))

# Optimized solution
n=int(eval(input()))
a=list(map(int,input().split()))
b=[0]
b.extend(a)
b.append(0)
a=b
base=0
for i in range(n+1):
    base+=abs(a[i+1]-a[i])
ans=[]
for i in range(1,n+1):
    ans.append(base+abs(a[i+1]-a[i-1])-abs(a[i+1]-a[i])-abs(a[i]-a[i-1]))
for i in range(n):
    print((ans[i]))
# Original solution
N=int(eval(input()))
A=list(map(int,input().split()))
for i in range(N):
    B=[0]+A[0:i]+A[i+1:N]+[0]
    print((sum([abs(B[j]-B[j+1]) for j in range(N)])))

# Optimized solution
N=int(eval(input()))
A=list(map(int,input().split()))
A=[0]+A+[0]
cost=sum([abs(A[k]-A[k+1]) for k in range(N+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(cost)
    else:
        print((cost-abs(A[i-1]-A[i])-abs(A[i]-A[i+1])+abs(A[i-1]-A[i+1])))
# Original solution
n = int(eval(input()))
s = [list(map(int,input().split())) for i in range(n)]
from itertools import permutations
def distance(s):
    res = 0
    for i in range(n-1):
        res += ((s[i][0]-s[i+1][0])**2 + (s[i][1]-s[i+1][1])**2)**0.5
    return res
k = 0
for key in list(permutations(s,n)):
    k += distance(key)
fin_res = format(k/len(list(permutations(s,n))),'.10f')
print(fin_res)

# Optimized solution
n = int(eval(input()))
s = [list(map(int,input().split())) for i in range(n)]
from itertools import permutations
perm = list(permutations(s,n))
def distance(s):
    res = 0
    for i in range(n-1):
        res += ((s[i][0]-s[i+1][0])**2 + (s[i][1]-s[i+1][1])**2)**0.5
    return res
k = 0
for key in perm:
    k += distance(key)
fin_res = format(k/len(perm),'.10f')
print(fin_res)