import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

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

main = do
    [n, k] <- getIntList
    print $ foldl' (\x y -> (x+y) `mod` 1000000007) 0 [sum [n,n-1..n-i+1] - sum [0..i-1] + 1| i <- [k..n+1]]