CodeEff/ECCO huggingface dataset:
# Original solution
n = int(eval(input()))
array = [int(x) for x in input().split()]

tmp_res = 0
tmp_ici = 0
tmp_array = []
for i in array:
    tmp_array.append(abs(tmp_ici-i))
    tmp_ici = i
tmp_array.append(abs(tmp_ici-0))

array = [0] + array + [0]
for i in range(n):
    c = array[i]
    cc = array[i+2]
    a = tmp_array[:i]
    b = tmp_array[i+2:]
    print((sum(a)+abs(c-cc)+sum(b)))

# Optimized solution
n = int(eval(input()))
array = [int(x) for x in input().split()]

tmp_res = 0
tmp_ici = 0
tmp_array = []
for i in array:
    tmp_array.append(abs(tmp_ici-i))
    tmp_ici = i
tmp_array.append(abs(tmp_ici-0))
tmp_sum = sum(tmp_array)

array = [0] + array + [0]
for i in range(n):
    c = array[i]
    cc = array[i+2]
    a = sum(tmp_array[i:i+2])
    print((tmp_sum-a+abs(c-cc)))
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))
a.insert(0,0)
a.insert(n+1,0)
total=0
for i in range(1,n+2):
    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)

# Optimized solution
n=int(eval(input()))
a=list(map(int,input().split()))
a.insert(0,0)
a.insert(n+1,0)
total=0
for i in range(n+1):
    total+=abs(a[i+1]-a[i])
for i in range(n):
    print((total-abs(a[i+1]-a[i])-abs(a[i+2]-a[i+1])+abs(a[i+2]-a[i])))
# Original solution
#C - Traveling Plan
N = int(eval(input()))
A = list(map(int, input().split()))
DP = []
ans = []
DP.append(abs(0-A[0]))
for i in range(1,N):
    DP.append(abs(A[i]-A[i-1]))

for j in range(N):
    DP2 = DP[:]
    #DP2.pop(j)

    if j == 0:
        DP2[j+1] = abs(A[j+1])
        tmp = sum(DP2)-DP2[0]+abs(A[N - 1])
    elif j == N-1:
        tmp = sum(DP2)-DP2[N-1]+abs(A[N - 2])
    else:
        tmp = sum(DP2) + abs(A[N - 1])-DP2[j]-DP2[j+1]+abs(A[j+1]-A[j-1])
    ans.append(tmp)

for i in range(len(ans)):
    print((ans[i]))


# Optimized solution
#C - Traveling Plan
N = int(eval(input()))
A = list(map(int, input().split()))
DP = []
ans = []
DP.append(abs(0-A[0]))
for i in range(1,N):
    DP.append(abs(A[i]-A[i-1]))

sum_DP = sum(DP)

for j in range(N):
    if j == 0:
        tmp = sum_DP-DP[0]-DP[1]+abs(A[1])+abs(A[N - 1])
    elif j == N-1:
        tmp = sum_DP-DP[N-1]+abs(A[N - 2])
    else:
        tmp = sum_DP + abs(A[N - 1])-DP[j]-DP[j+1]+abs(A[j+1]-A[j-1])
    ans.append(tmp)

for i in range(len(ans)):
    print((ans[i]))
# Original solution
n = int(eval(input()))
x = list(map(int,input().split()))
cost = 0
for i in range(n):
    y = x[:i]+x[i+1:]
    cost+=abs(y[0])+abs(y[n-2])
    for j in range(n-2):
        cost+=abs(y[j]-y[j+1])
    print(cost)
    cost=0

# Optimized solution
n = int(eval(input()))
x = list(map(int,input().split()))
x = [0]+x+[0]
cost = 0
for i in range(n+1):
    cost+=abs(x[i]-x[i+1])
for i in range(1,n+1):
    cost2 = cost - abs(x[i]-x[i-1]) - abs(x[i]-x[i+1]) + abs(x[i-1]-x[i+1])
    print(cost2)
# Original solution
n = int(eval(input()))
lst = list(map(int, input().split()))
lst.insert(0, 0)
lst.append(0)

s = 0
for i in range(len(lst)-1):
    s += abs(lst[i+1]-lst[i])
    
for i in range(1, len(lst)-1):
    a = lst[i-1]
    b = lst[i]
    c = lst[i+1]
    if (b - a > 0 and c - b > 0) or (b - a < 0 and c - b < 0):
        print(s)
    else:
        print((s - abs(b-a) - abs(c-b) + abs(c-a)))

# Optimized solution
n = int(eval(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])))
# Original solution
import copy

N = int(eval(input()))
A = list(int(i) for i in input().split())
A.insert(0, 0)
A.append(0)
B = copy.deepcopy(A)
Q = 0

for i in range(N):
    A.pop(i+1)
    for j in range(N):            
        Q += abs(A[j] - A[j+1])
    print(("%d" % (Q)))
    Q = 0
    A = copy.deepcopy(B)

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

Sum = 0
Ans = 0

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

for i in range(N):
    Ans = Sum
    Ans = Ans - abs(A[i+1] - A[i]) - abs(A[i+2] - A[i+1]) + abs(A[i+2] - A[i])
    print(("%d" % (Ans)))
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))

for i in range(n):
  ans = 0
  t = 0
  for j in range(n):
    if i == j: continue
    ans += abs(t - a[j])
    t = a[j]
  ans += abs(t)
  print(ans)

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

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

ans = sum(nums)
for i in range(1,n+1):
  print((ans - nums[i-1]-nums[i]+abs(a[i+1]-a[i-1])))
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))
answer = []

for x, y in enumerate(a):
  sum = 0
  present = 0
  for s, t in enumerate(a):
    if s != x:
      cost = abs(t-present)
      sum += cost
      present = t
  sum += abs(present-0)
  answer.append(sum)
  print(sum)


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


sum = 0
present = 0
for s, t in enumerate(a):
  sum += abs(t-present)
  present = t
sum += abs(present-0)

for i, each in enumerate(a):
  if i == 0:
    prev = 0
    tmp = each
    next = a[i+1]
  elif i == len(a)-1:
    prev = a[i-1]
    tmp = each
    next = 0
  else:
    prev = a[i-1]
    tmp = each
    next = a[i+1]

  before = abs(prev-tmp) + abs(tmp - next)
  after = abs(prev - next)

  print((sum - before + after))
# 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]
    cnt=0
    for j in range(n):
        cnt+=abs(B[j+1]-B[j])
    print(cnt)

# Optimized solution
n=int(eval(input()))
A=list(map(int,input().split()))
A=[0]+A+[0]
cnt=0
for i in range(n+1):
    cnt+=abs(A[i+1]-A[i])

for i in range(1,n+1):
    if (A[i-1]-A[i])*(A[i]-A[i+1])>=0:
        print(cnt)
    else:
        print((cnt-abs(A[i-1]-A[i])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1])))
# Original solution
from math import fabs
N=int(eval(input()))
pos=list(map(int,input().split()))

for i in range(N):
    pos_=pos.copy()
    del pos_[i]
    pos_.insert(0,0)
    pos_.insert(N+1,0)
    x=0
    for j in range(N):
        x+=fabs(pos_[j+1]-pos_[j])
    print((int(x)))
    

# Optimized solution
from math import fabs
N=int(eval(input()))
pos=list(map(int,input().split()))
pos.insert(0,0)
pos.insert(N+1,0)
total_len=0
for i in range(N+1):
    total_len+=fabs(pos[i+1]-pos[i])
    

for i in range(N):
    total=total_len-fabs(pos[i+1]-pos[i])-fabs(pos[i+2]-pos[i+1])+fabs(pos[i+2]-pos[i])
    print((int(total)))
# Original solution
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C


if __name__ == '__main__':
    spot_count = int(eval(input()))
    mod_spots = [0] + list(map(int, input().split())) + [0]

    for i in range(spot_count):
        tmp = mod_spots[i + 1]

        if mod_spots[i] <= mod_spots[i + 2]:
            mod_spots[i + 1] = mod_spots[i]
        elif (mod_spots[i] > 0) and mod_spots[i + 2] > 0:
            mod_spots[i + 1] = 0
        else:
            mod_spots[i + 1] = mod_spots[i]

        cost = {j: abs(mod_spots[j + 1] - mod_spots[j]) for j in range(spot_count + 1)}
        mod_spots[i + 1] = tmp
        print((sum(cost.values())))


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

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    spot_count = int(eval(input()))
    spots = [0] + list(map(int, input().split())) + [0]

    # See:
    # https://www.youtube.com/watch?v=WFg2yJGZ2Cw
    # https://img.atcoder.jp/arc093/editorial.pdf
    total_distance = 0
    total_cost = 0

    for i in range(spot_count + 1):
        total_distance += abs(spots[i + 1] - spots[i])

    for j in range(1, spot_count + 1):
        shortcut_cost = (abs(spots[j - 1] - spots[j]) + abs(spots[j] - spots[j + 1]))
        total_cost = total_distance + abs(spots[j - 1] - spots[j + 1]) - shortcut_cost
        print(total_cost)
# Original solution
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
    tmp=a.copy()
    tmp.pop(i)
    for j in range(1,n+1):
        ans+=abs(tmp[j]-tmp[j-1])
    print(ans)

# Optimized solution
N=int(eval(input()))
A=list(map(int,input().split()))+[0]
A.insert(0,0)
cost=0
for i in range(N+1):
    cost+=abs(A[i+1]-A[i])
for i in range(1,N+1):
    print((cost-abs(A[i+1]-A[i])-abs(A[i]-A[i-1])+abs(A[i+1]-A[i-1])))
# Original solution
import copy

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

a = [0] + a + [0]

for i in range(n):
  my_sum = 0
  l = copy.copy(a)
  del l[i+1]
  for j in range(n):
    my_sum += abs(l[j] - l[j+1])
  print(my_sum)

# Optimized solution
N = int(eval(input()))
A = [int(i) for i in input().split()]

A.insert(0,0)
A.append(0)

S = 0

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

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])))
# Original solution
n = int(eval(input()))
ls = list(map(int,input().split()))
di = [0]*(n+1)
di[0] = abs(ls[0])
di[-1] = abs(ls[-1])
for i in range(1,n):
    di[i] = abs(ls[i] - ls[i-1])
for j in range(n):
    if j == 0:
        if (ls[j])*(ls[j+1]-ls[j]) < 0:
            print((sum(di)-di[j]-di[j+1]+max(di[j],di[j+1])-min(di[j],di[j+1])))
        else:
            print((sum(di)))
    elif j == n-1:
        if (ls[j]-ls[j-1])*(-ls[j]) < 0:
            print((sum(di)-di[j]-di[j+1]+max(di[j],di[j+1])-min(di[j],di[j+1])))
        else:
            print((sum(di)))
    else:
        if (ls[j]-ls[j-1])*(ls[j+1]-ls[j]) < 0:
            print((sum(di)-di[j]-di[j+1]+max(di[j],di[j+1])-min(di[j],di[j+1])))
        else:
            print((sum(di)))

# Optimized solution
n = int(eval(input()))
ls = list(map(int,input().split()))
di = [0]*(n+1)
ls = [0] + ls + [0]
for i in range(n+1):
    di[i] = abs(ls[i+1] - ls[i])
mx = sum(di)
for j in range(1,n+1):
    print((mx-di[j-1]-di[j]+abs(ls[j+1]-ls[j-1])))
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))
for i in range(n):
    t = 0
    w = a[:i] + a[i+1:]
    w.append(0)
    w.insert(0,0)
    for h in range(len(w)-1):
        t += abs(w[h]-w[h+1])
    print(t)

# Optimized solution
n = int(eval(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))
# Original solution
N = int(eval(input()))
A = [int(a) for a in input().split()]
ans = abs(A[0]) + abs(A[N-1])
for i in range(N-1):
    ans+=abs(A[i+1]-A[i])
ans = [ans] * N
for i in range(N):
    A_1 = A[i]
    if i==0:
        A_0 = 0
        A_2 = A[i+1]
    elif i==N-1:
        A_0 = A[i-1]
        A_2 = 0
    else:
        A_0 = A[i-1]
        A_2 = A[i+1]
    ans[i] += -abs(A_1-A_0) - abs(A_1-A_2) + abs(A_2-A_0)
    print((ans[i]))

# Optimized solution
N = int(eval(input()))
A = [int(a) for a in input().split()]
ans = abs(A[0]) + abs(A[N-1])
for i in range(N-1):
    ans+=abs(A[i+1]-A[i])
for i in range(N):
    A_1 = A[i]
    if i==0:
        A_0 = 0
        A_2 = A[i+1]
    elif i==N-1:
        A_0 = A[i-1]
        A_2 = 0
    else:
        A_0 = A[i-1]
        A_2 = A[i+1]
    tmp = ans -abs(A_1-A_0) - abs(A_1-A_2) + abs(A_2-A_0)
    print(tmp)
# Original solution
n=int(input())
a=list(map(int,input().split()))
cost=0
for i in range(n):
  cost=0
  A=a[:]
  if i==0:
    A[i]=0
  else:
    A[i]=A[i-1]
  cost+=abs(A[0]-0)
  for j in range(n-1):
    cost+=abs(A[j+1]-A[j])
  cost+=abs(0-A[-1])
  print(cost,end="\n")


# Optimized solution
n=int(eval(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])-abs(A[i]-A[i-1])+abs(A[i+1]-A[i-1])))
# Original solution
a=int(eval(input()))
b=list(map(int,input().split()))
d=[]
d.append(0)
for i in range(a):
	d.append(b[i])
for i in range(1,a+1):
	sumx=0
	if(i==a):
		e=d[:i]
	else:
		e=d[:i]+d[i+1:]
	for j in range(1,len(e)):
		sumx+=abs(e[j]-e[j-1])
	sumx+=abs(e[-1]-0)
	print(sumx)

# Optimized solution
a=int(eval(input()))
b=list(map(int,input().split()))
d=[]
d.append(0)
d=d+b
sumx=0
for i in range(1,a+1):
	sumx+=abs(d[i]-d[i-1])
for i in range(1,a):
	sumx1=sumx-abs(d[i]-d[i-1])-abs(d[i+1]-d[i])+abs(d[i+1]-d[i-1])
	sumx1+=abs(d[-1]-0)
	print(sumx1)
sumx1=sumx-abs(d[-1]-d[-2])+abs(d[-2]-0)
print(sumx1)
# Original solution
import copy
N = int(eval(input()))
A = list(map(int,input().split()))
A.insert(0,0)
A.append(0)
dif = []
for i in range(N + 1):
	dif.append((abs(A[i+1] - A[i])))

for i in range(N):
	temp_dif = copy.copy(dif)
	del temp_dif[i + 1]
	del temp_dif[i]
	temp_dif.append(abs(A[i + 2] - A[i]))
	print((sum(temp_dif)))

# Optimized solution

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

temp_sum = sum(dif)
for i in range(N):
	print((temp_sum - dif[i] - dif[i+1] + abs(A[i+2] - A[i])))
# Original solution
def read_line(*types): return [f(a) for a, f in zip(input().split(), types)]

n, = read_line(int)
a = read_line(*([int] * n))

def price(aa, skip):
    sum = 0

    prev = 0
    for i in range(len(aa)):
        if i == skip:
            continue
        sum += abs(prev - aa[i])
        prev = aa[i]

    sum += abs(prev)
    return sum

for i in range(len(a)):
    print((price(a, i)))


# Optimized solution
#!/usr/bin/env python

def read_line(*types): return [f(a) for a, f in zip(input().split(), types)]

n, = read_line(int)
a = read_line(*([int] * n))

def price(aa):
    sum = 0

    prev = 0
    for i in range(len(aa)):
        sum += abs(prev - aa[i])
        prev = aa[i]

    sum += abs(prev)
    return sum

aa = [0] + a + [0]
price_all = 0

for i in range(len(aa) - 1):
    price_all += abs(aa[i] - aa[i + 1])

for i in range(1, len(aa) - 1):
    p = price_all
    p -= abs(aa[i - 1] - aa[i])
    p -= abs(aa[i] - aa[i + 1])
    p += abs(aa[i - 1] - aa[i + 1])
    print(p)
# Original solution
# input
N = int(eval(input()))
A = list(map(int, input().split()))

full_root = [0] + A + [0]
full_place = [abs(full_root[i] - full_root[i + 1]) for i in range(N + 1)]
# check
for ind in range(1, N + 1):
    if ind == 1:
        res = sum(full_place[2:])
    elif ind == N + 1:
        res = sum(full_place[:-2])
    else:
        res = sum(full_place[:ind - 1] + full_place[ind + 1:])

    print((res + abs(full_root[ind - 1] - full_root[ind + 1])))


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

full_root = [0] + A + [0]
full_place = [abs(full_root[i] - full_root[i + 1]) for i in range(N + 1)]
full_res = sum(full_place)
# check
for ind in range(1, N + 1):
    res = full_res - sum(full_place[ind - 1:ind + 1]) + abs(full_root[ind - 1] - full_root[ind + 1])

    print(res)
# Original solution
n = int(eval(input()))
l = list(map(int,input().split()))
s = 0
for i in range(n):
  a = [0]+l[:i]+l[i+1:]+[0]
  for j in range(len(a)-1):
    s += abs(a[j+1]-a[j])
  print(s)
  s = 0
  

# Optimized solution
n = int(eval(input()))
l = [0]+list(map(int,input().split()))+[0]
s = 0
for j in range(len(l)-1):
    s += abs(l[j+1]-l[j])
for i in range(1,n+1):
  a = l[i-1]
  b = l[i]
  c = l[i+1]
  if a<=b<=c:
    print(s)
  elif a<=c<=b:
    print((s-2*(b-c)))
  elif b<=a<=c:
    print((s-2*(a-b)))
  elif b<=c<=a:
    print((s-2*(c-b)))
  elif c<=a<=b:
    print((s-2*(b-a)))
  elif c<=b<=a:
    print(s)
# Original solution
n = int(eval(input()))
a = [int(i) for i in input().split()]
a.insert(0, 0)
a.append(0)

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

for j in range(n):
  answer = sum([abs(i) for i in gap[0:j]]) + abs(gap[j] + gap[j + 1]) + sum([abs(i) for i in gap[j + 2:]])
  print(answer)


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

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

base = sum([abs(i) for i in gap])

for j in range(n):
  answer = base - (abs(gap[j]) + abs(gap[j + 1])) + abs(gap[j] + gap[j + 1])
  print(answer)
# Original solution
import copy
N = int(eval(input()))
A = list(map(int, input().split()))
for i in range(N):
    answer = 0
    del_A = copy.copy(A)
    del_A.remove(A[i])
    answer += abs(del_A[0])
    for j in range(1, N-1):
        answer += abs(del_A[j] - del_A[j-1])
    answer += abs(del_A[-1])
    print(answer)

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

for i in range(N):
    answer = all
    if i == 0:
        prev = 0
    else:
        prev = A[i-1]
    if i == N-1:
        next = 0
    else:
        next = A[i+1]
    curr = A[i]
    if prev > curr and curr < next:
        if prev >= next:
            answer -= abs(curr - next) * 2
        else:
            answer -= abs(curr - prev) * 2
    elif prev < curr and curr > next:
        if prev >= next:
            answer -= abs(curr - prev) * 2
        else:
            answer -= abs(curr - next) * 2
    print(answer)
# Original solution
N = int(eval(input()))
array = list(map(int,input().split()))
expense = [0] * (N+1)
expense[0] = abs(array[0])
for i in range(N-1):
    expense[i+1] = abs(array[i+1] - array[i])
expense[N] = abs(array[N-1])
total = sum(expense)
for i in range(N):
    tmp = total
    tmp -= expense[i]+expense[i+1]
    tmp += (abs(array[i+1] - array[i-1]) if i != 0 else abs(array[i+1])) if i != N-1 else abs(array[N-2])
    print(tmp)

# Optimized solution
N = int(eval(input()))
arr = [0] + list(map(int, input().split())) + [0]
ans = 0
for i in range(1,len(arr)):
    ans += abs(arr[i]-arr[i-1])
for i in range(1,len(arr)-1):
    print((ans-abs(arr[i-1]-arr[i])-abs(arr[i+1]-arr[i])+abs(arr[i-1]-arr[i+1])))
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))
for i in range(n):
    sum=0
    c=0
    for j in range(n):
        if i==j:
            continue
        else:
            d=abs(c-a[j])
            sum+=d
            c=a[j]
    sum+=abs(c)
    print(sum)


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

for i in range(n):
  B = [0] + A[:i] + A[i+1:] + [0]
  ans = 0
  for j in range(n):
    ans += abs(B[j] - B[j+1])
  print(ans)

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

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

for i in range(1, n+1):
  print((cost - abs(A[i] - A[i-1]) - abs(A[i+1] - A[i]) + abs(A[i+1] -A[i-1])))
# Original solution
N = int(eval(input()))
A = [int(n) for n in input().split()]
A = [0] + A + [0]
L = []
LL = []

for i, a in enumerate(A):
    if i < len(A) - 1:
        L.append(abs(A[i] - A[i+1]))
    if i < len(A) - 2:
        LL.append(abs(A[i] - A[i+2]))

for i in range(N):
    ans = sum(L) - L[i] - L[i+1] + LL[i]
    print(ans)


# Optimized solution
N = int(eval(input()))
A = [int(n) for n in input().split()]
A = [0] + A + [0]
L = []
LL = []

for i, a in enumerate(A):
    if i < len(A) - 1:
        L.append(abs(A[i] - A[i+1]))
    if i < len(A) - 2:
        LL.append(abs(A[i] - A[i+2]))

s = sum(L)

for i in range(N):
    ans = s - L[i] - L[i+1] + LL[i]
    print(ans)
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))
a.append(0)
for i in range(n):
    x = 0
    s = 0
    for j in range(n+1):
        if i != j:
            s += abs(x - a[j])
            x = a[j]
    print(s)


# Optimized solution
n = int(eval(input()))
l = list(map(int, input().split()))
a = [0] + l + [0]
s = 0
x = 0
for i in range(n + 2):
    s += abs(x - a[i])
    x = a[i]

for i in range(1, n + 1):
    t = s + abs(a[i + 1] - a[i - 1])
    t = t - abs(a[i] - a[i - 1])
    t = t - abs(a[i + 1] - a[i])
    print(t)
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))
x = 0
c_lst = []

for i in a:
    c = 0
    for j in a:
        if i == j:
            continue

        c += abs(j-x)
        x = j

    c += abs(x-0)
    c_lst.append(c)
    x = 0

for i in c_lst:
    print(i)


# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
x = 0
c_lst = []

s = 0
for i in a:
    s += abs(i-x)
    x = i
s += abs(0-x)

b, f = 0, 0

for i in range(len(a)):
    if i == 0:
        f, b = 0, a[i+1]
    elif i == len(a)-1:
        f, b = a[i-1], 0
    else:
        f, b = a[i-1], a[i+1]

    c = s + abs(b-f) - (abs(a[i]-f)+abs(b-a[i]))
    c_lst.append(c)

for i in c_lst:
    print(i)
# Original solution
import sys
input = sys.stdin.readline
n = int(eval(input()))
a = list(map(int,input().split()))

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


abs2 = [0]*(n-2)
for i in range(2,n):
    abs2[i-2] = abs(a[i-2]-a[i])
#print(abs1)

b_0 = abs(a[0])
b_1 = abs(a[1])
b_n1 = abs(a[n-1])
b_n2 = abs(a[n-2])

for i in range(n):
    p = a[:i] + a[i+1:]
    if i == 0:
        print((abs1_sum - abs1[0] + b_1 + b_n1))
    elif i == n-1:#
        #print(abs1[:n-2],abs(p[0]),abs(p[-1]))
        print((abs1_sum - abs1[-1] + b_0 + b_n2))
    else:
        print((b_0 + b_n1 + abs1_sum - abs1[i] - abs1[i-1] + abs2[i-1]))

    




# Optimized solution
import sys
input = sys.stdin.readline
n = int(eval(input()))
a = list(map(int,input().split()))

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


abs2 = [0]*(n-2)
for i in range(2,n):
    abs2[i-2] = abs(a[i-2]-a[i])
#print(abs1)

b_0 = abs(a[0])
b_1 = abs(a[1])
b_n1 = abs(a[n-1])
b_n2 = abs(a[n-2])
ans = []
for i in range(n):
    if i == 0:
        ans.append(abs1_sum - abs1[0] + b_1 + b_n1)
    elif i == n-1:#
        #print(abs1[:n-2],abs(p[0]),abs(p[-1]))
        ans.append(abs1_sum - abs1[-1] + b_0 + b_n2)
    else:
        ans.append(b_0 + b_n1 + abs1_sum - abs1[i] - abs1[i-1] + abs2[i-1])

for i in range(n):
    print((ans[i]))
# Original solution
n,*a=list(map(int,open(0).read().split()));c=[0]+a+[0]
for i in range(n):s,t,r=c[i:i+3];print((sum(abs(c[t]-c[t+1])for t in range(n+1))+abs(r-s)-abs(t-s)-abs(t-r)))

# Optimized solution
n,*a=list(map(int,open(0).read().split()));c=[0]+a+[0]
y=sum(abs(c[t]-c[t+1])for t in range(n+1))
for i in range(n):s,t,r=c[i:i+3];print((y+abs(r-s)-abs(t-s)-abs(t-r)))
# Original solution
n = int(eval(input()))
l = list(map(int,input().split()))
count = [abs(l[0])]
for i in range(1,n):
    count.append(count[-1]+abs(l[i]-l[i-1]))
count.append(count[-1]+abs(l[n-1]))
if 0 <= l[0] <= l[1] or 0 >= l[0] >= l[1]:
    print((count[-1]))
else:
    ans = count[-1]-(abs(l[0])+abs(l[1]-l[0]))+abs(l[1])
    print(ans)
for i in range(1,n-1):
    if l[i-1] <= l[i] <= l[i+1] or l[i-1] >= l[i] >= l[i+1]:
        print((count[-1]))
    else:
        ans = count[-1]-(abs(l[i]-l[i-1])+abs(l[i+1]-l[i]))+abs(l[i+1]-l[i-1])
        print(ans)
if 0 <= l[n-1] <= l[n-2] or 0>= l[n-1] >= l[n-2]:
    print((count[-1]))
else:
    ans = count[-1]-(abs(l[n-1])+abs(l[n-1]-l[n-2]))+abs(l[n-2])
    print(ans)

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

count = 0
for i in range(1,n+2):
    count+=+abs(l[i]-l[i-1])
for i in range(1,n+1):
    if l[i-1] <= l[i] <= l[i+1] or l[i-1] >= l[i] >= l[i+1]:
        print(count)
    else:
        print((count-(abs(l[i]-l[i-1])+abs(l[i+1]-l[i]))+abs(l[i+1]-l[i-1])))