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

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


    do j=1,n
        m(1,j)=(-1)**(j+1)
    end do

    do i=2,n
        m(i,1)=m(i-1,n)
        do j=2,n
            m(i,j)=m(i-1,j-1)
        end do
    end do

    a=0
    do i=1,n
        do j=1,n
            a(i)=a(i)+m(i,j)*b(j)
        end do
    end do

    write(*,*) a
stop
contains
end program kadai
