program main
  implicit none
  integer(8) :: N,K
  integer(8) :: i_max, i_min
  integer(8) :: out, i
  read(*,*) N,K
  i_min = 0
  do i = 0,K-1
     i_min = i_min + i
  end do
  i_max = 0
  do i = N,N-K+1,-1
     i_max = i_max + i
  end do
  out = 0
  out = out + mod( i_max - i_min + 1,10**9+7) 
  do i = K+1,N+1
     i_min = i_min + i-1 
     i_max = i_max + (N-i+1 )
     out = out + mod(i_max - i_min + 1,10**9+7) 
  end do
  write(*,'(i0)') mod(out,10**9+7)
end program main
