program sample
	implicit none
    integer :: x,y,i,sum1,maxval1,minval1
    integer, allocatable :: a(:)
    
    read(*,*) x,y
    
    allocate(a(x))
    
    do i=1,x
       a(i)=y+i-1
    end do
    
    write(*,*) a
    
    sum1=sum(a)
    maxval1=maxval(a)
	minval1=minval(a)
    
    if (maxval1 >=0 .and. minval1<=0) then
    	write(*,*) sum1
    else if (minval1>0) then
    	write(*,*) sum1-minval1
    else
    	write(*,*) sum1-maxval1
    end if
    
    deallocate(a)
    
    stop
end program sample