program probC
  implicit none
  integer,allocatable :: a(:), b(:)
  integer i,ans1,n,now

  read(*,*) n
  allocate(a(n),b(n))
  read(*,*) a(1:n)
  b = a

  call quicksort(b,1,n)
!  write(*,*)b

  now=0
  ans1=0
  do i =1,n
     ans1 = ans1 + abs(now-b(i))
     now = b(i)
  end do
  
  ans1=ans1+abs(b(n))
!  write(*,*)ans1,minval(a)

  do i = 1,n
     if(a(i).ne.b(1) .and. a(i).ne.b(n))then
        write(*,*) ans1
     else
        if(a(i)==b(1)) write(*,*) ans1 - min(abs(b(1)-b(2)),abs(b(1)-0))*2
        if(a(i)==b(n)) write(*,*) ans1 - min(abs(b(n)-b(n-1)),abs(b(n)-0))*2
     end if
  end do
  
end program probC

recursive subroutine quicksort(a, first, last)
  implicit none
  integer a(*)
  integer first, last
  integer i, j
  integer x, t

  x = a( (first+last) / 2 )
  i = first
  j = last
  do
     do while (a(i) < x)
        i=i+1
     end do
     do while (x < a(j))
        j=j-1
     end do
     if (i >= j) exit
     t = a(i);  a(i) = a(j);  a(j) = t
     i=i+1
     j=j-1
  end do
  if (first < i - 1) call quicksort(a, first, i - 1)
  if (j + 1 < last)  call quicksort(a, j + 1, last)
  end subroutine quicksort
