      PROGRAM sumOfLargeNumbers
      IMPLICIT NONE
      integer(16) :: n,k
      integer(16),allocatable :: up(:)
      integer(16) :: i, ma,mi, ans
      integer(16),parameter :: modulus = 10**9+7
      
      read*,n,k
      
      allocate( up(n+1) )
      do i = 1,n+1
        up(i) = i-1
      end do
      
      
      ans = 0
      
      !first case
      i = k
      ma = sum( up((n+1)-i+1:(n+1)) )
      mi = sum( up(1:i) )
      ans = mod( ans+(ma-mi+1), modulus )
      
      do i = k+1,n+1
        !Max, min
        ma = ma + up( (n+1)-i+1 )
        mi = mi + up( i )
        
        ans = mod(ans+(ma-mi+1),modulus)
      end do
      
      print*,ans
      
      
      END PROGRAM