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

    read(*,*) n
    allocate(a(n))
    allocate(m(n,n))
    allocate(b(n))
!read(*,*) test
    read(*,*) b
 !   b=test
    !write(*,*) "1"


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

!write(*,*) "2"
    do i=2,n
        if (mod(i,3)==2) then
            m(i,1)=m(1,n)
            do j=2,n
                m(i,j)=m(1,j-1)
            end do
        else if (mod(i,3)==0) then
            m(i,1)=m(2,n)
            do j=2,n
                m(i,j)=m(2,j-1)
            end do
        else
            m(i,:)=m(1,:)
        end if
    end do
!write(*,*) "4"
    a=0
    do i=1,n
        do j=1,n
            a(i)=a(i)+m(i,j)*b(j)
        end do
    end do

!m=transpose(m)
   ! write(*,*) m
    write(*,*) a
stop
contains
end program kadai