read N
read A

A="0 ${A} 0"
A=($A)

for ((i=0; i<${N}; i++)); do

    route="0 "

    for ((j=0; j<${N}; j++)); do

        if [ $j -ne $i ]; then

            route+="${A[( j + 1 )]} "

        fi

    done

    route+="0"
    #echo $route

    B=($route)
    sum=0

    for ((k=0; k<${N}; k++)); do

        #echo $(( (i < 0 ? 1 : 2 * -1) + ( i < 0 ? 1 : 2 * -1) ))

        sum=$(( B[k] - B[k+1] < 0 ? sum + ( B[k] - B[k+1] ) * -1 : sum + ( B[k] - B[k+1]) ))
        #echo $sum

        #c=(( ${A[k]} - ${A[( k + 1)]} ))
        
    done
    echo ${sum}

done

