program rotation_sort
  implicit none
  integer :: n, p(5000) = 0, i, j
  integer(8) :: a, b, dp(0:5000,0:5000) = 0_8
  read(*,*) n, a, b
  read(*,*) p(1:n)
  do i = 1, n
    do j = 0, n
      dp(i,j) = dp(i-1,j)
      if (j < p(i)) then
        dp(i,j) = dp(i,j)+a
      else if (j > p(i)) then
        dp(i,j) = dp(i,j)+b
      end if
      if (j > 0) dp(i,j) = min(dp(i,j),dp(i,j-1))
    end do
  end do
  write(*,'(i0)') dp(n,n)
end program rotation_sort