program colorful_slimes
  implicit none
  integer :: n, i, j, k
  integer(8) :: x, a(4000)
  a = 0_8
  read(*,*) n, x
  read(*,*) a(1:n)
  a(n+1:2*n) = a(1:n)
  do k = 1, 3
    do i = n+1, 2*n
      do j = i-n-1, i-1
        a(i) = min(a(i),a(j)+int(i-j,8)*x)
      end do
      a(i-n) = a(i)
    end do
  end do
  write(*,'(i0)') sum(a(1:n))
  stop
end program colorful_slimes