program kadai
    implicit none
    integer  ::  n
    integer(8),allocatable  ::  a(:)
    integer(8),allocatable  ::  b(:)
    integer,allocatable  ::  m(:,:)
integer(8)  ::  sum,sum2
    integer  ::  i,j,test

    read(*,*) n
    allocate(a(n))
    allocate(b(n))

    read(*,*) b
    sum=0
    sum2=0
    do i=1,n
        sum=sum+b(i)
    end do
    do i=2,n-1
        sum2=sum2+b(i)
    end do
    a(1)=sum-2*sum2

    do i=1,n-1
        a(i+1)=2*b(i)-a(i)
    end do

    write(*,*) a

stop
contains

end program kadai