program RainFlowsintoDams
    implicit none
    integer(4):: n, i
    integer(8), allocatable:: a(:), ans(:)

    read*, n
    allocate(a(n), ans(n))
    read*, a(:)

    ans(:) = 0
    ans(1) = sum(a) - 2*sum(a(2:n:2))

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

    print*, ans(:)

end program RainFlowsintoDams