program polynomial_construction
  implicit none
  integer :: p, a(0:3000) = 0, b(0:3000) = 0, i, j
  integer :: f(0:3000) = 0, g(0:3000) = 0, h
  read(*,*) p
  read(*,*) a(0:p-1)
  f(0) = 1
  do i = 1, p
    f(i) = mod(i*f(i-1),p)
  end do
  do i = 0, p-1
    if (a(i) == 0) cycle
    h = mod(f(i)*f(p-1-i),p)
    if (mod(p-1-i,2) == 1) h = p-h
    h = inv(h,p)
    g(0:p) = 0
    g(1) = 1
    g(p) = p-1
    do j = p-1, 0, -1
      b(j) = mod(b(j)+h*g(j+1),p)
      g(j) = mod(g(j)+i*g(j+1),p)
    end do
  end do
  write(*,*) b(0:p-1)
contains
  function inv(n,p) result(y)
    integer, intent(in) :: n, p
    integer :: a, b, x, y, t, q
    a = mod(n,p)
    b = p
    x = 0
    y = 1
    do while (b /= 0)
      q = a/b
      t = b
      b = mod(a,b)
      a = t
      t = y
      y = x
      x = t-q*x
    end do
    y = mod(y,p)
    if (y < 0) y = y+p
  end
end program polynomial_construction