read N
read A

all=( $(echo $A | sed -e "s/-*[0-9]*/-\0%\0/g" -e "s/ //g" -e "s/%/ /g") )

(( sum1 = (${all[0]}) ))
total=0

for i in $( seq 0 $N ); do

  #全てのスポットを回った場合の交通費の算出
  (( sum2 = (${all[i+1]:-0}) ))
  (( total += ${sum1/-/} ))

  #取りやめた場合の差分の算出
  (( sabun[i] = ( sum1*sum2>0?0:${sum1/-/}-${sum2/-/}) ))
  (( sabun[i] = ( sum1*sum2>0?0:-${sum1/-/}-${sum2/-/}+${sabun[i]/-/}) ))

  (( sum1 = sum2 ))

done

for i in $( seq 1 $N ); do
  echo $(( $total - ${sabun[i-1]/-/} ))
done
