program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: n,k,l,r,ans,i
    integer(int64),parameter:: md=1000000007

    read*, n,k

    l=0
    r=n
    ans=0
    do i=1,n+1
        if (i >= k) ans=mod(ans+(r+1-l),md)
        l=l+i
        r=r+(n-i)
    end do
    print*, ans
end program name