program sum_of_large_numbers
  implicit none
  integer(8), parameter :: md = 1000000007_8
  integer :: n, k, i
  integer(8) :: x = 0, s(0:200000) = 0
  read(*,*) n, k
  do i = 1, n
    s(i) = mod(s(i-1)+i,md)
  end do
  do i = k, n+1
    x = modulo(x+(s(n)-s(n-i))-(s(i-1)-s(0))+1,md)
  end do
  write(*,'(i0)') x
end program sum_of_large_numbers