read N
read A

base=$(echo $A | sed -e "s/[-]*[0-9]\+/\0)) \$((\0 -/g" -e "s/^/echo \$((0 - /" -e "s/$/ 0))/" | sh | sed -e "s/-//g" -e "s/ /\+/g" -e "s/^/echo \$((/" -e "s/$/))/" | sh)
A=($A)

for (( i=1; i<=N; i++ )); do

    if [ "${i}" = "1" ]; then
        c=$(echo "echo \$(( 0 - ${A[0]} ))" "\$(( ${A[0]} - ${A[1]} ))" "\$(( 0 - ${A[1]} ))")
    elif [ "${i}" = "${N}" ]; then
        c=$(echo "echo \$(( ${A[( i - 2 )]} - ${A[( i - 1 )]} ))" "\$(( ${A[( i - 1 )]} - 0 ))" "\$(( ${A[( i - 2 )]} - 0 ))")
    else
        c=$(echo "echo \$(( ${A[( i - 2 )]} - ${A[( i - 1 )]} ))" "\$(( ${A[( i - 1 )]} - ${A[( i - 0 )]} ))" "\$(( ${A[( i - 2 )]} - ${A[( i - 0 )]} ))")
    fi

    s=$(echo $c | sh | sed -e "s/-//g")
    s=($s)
    echo "echo \$(( $base - ${s[0]} - ${s[1]} + ${s[2]}))" | sh

done