program sum_of_large_numbers
  implicit none
  integer(8), parameter :: m = 1000000007_8, h = (m+1)/2, s = (m+1)/6
  integer(8) :: n, k, i
  read(*,*) n, k
  write(*,'(i0)') modulo(f(n+1)-f(k-1),m)
contains
  integer(8) function f(i)
    integer(8), intent(in) :: i
    f = i*mod((n+1)*mod(h*(i+1),m)-mod(s*mod((i+1)*(i*2+1),m),m)+1,m)
  end
end program sum_of_large_numbers