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(x(n+1)-x(k-1),m)
contains
  integer(8) function f(i)
    integer(8), intent(in) :: i
    f = mod(mod(h*i,m)*(i+1),m)
  end
  integer(8) function g(i)
    integer(8), intent(in) :: i
    g = mod(mod(s*i,m)*mod((i+1)*(i*2+1),m),m)
  end
  integer(8) function x(i)
    integer(8), intent(in) :: i
    x = mod((n+1)*f(i)-g(i)+i,m)
  end
end program sum_of_large_numbers