import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector.Unboxed as VU
import qualified Data.Map.Strict as M

main = abc163d

abc163d = do
    [n,k] <- getIntList
    let len = fromIntegral n + 1 :: Int
    print $ mod (solveD len (fromIntegral k) 0) (10^9 + 7)

solveD len k ans
    | len == k = ans + 1
    | otherwise = solveD len (k + 1) (ans + max - min + 1)
    where min = k * (k - 1) `div` 2
          max = min + k * (len - k)

readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words
getIntList = readIntList <$> BS.getLine