program main
  implicit none
  integer(8) n,x,i,idxmin,j,k,cnt
  integer(8),allocatable::a(:),b(:)
  read*,n,x
  allocate(a(n),b(n))
  read*,a
  idxmin=minloc(a,1)
  b(:)=1d9+1
  b(idxmin)=a(idxmin)
  cnt=0
  do i=idxmin-1,idxmin+n-2
     j=mod(i,n)+1
     k=mod(i+1,n)+1
     if(b(j)+x.lt.a(k)) then
        cnt=cnt+1
        b(k)=b(j)+x
     else
        b(k)=a(k)
     endif
  end do
  print*,sum(pack(a,a==b))+cnt*x+cnt
end program main