import           Data.Char                      ( isSpace )
import           Data.List
import qualified Data.ByteString.Char8         as C

main = do
    [n, k] <- unfoldr (C.readInt . C.dropWhile isSpace) <$> C.getLine
    let minmax  = n * (n + 1) `div` 2
        mindiff = [n, n - 1 ..]
        minList = scanl (-) minmax mindiff
        maxdiff = [0, 1 ..]
        maxList = scanl (-) minmax maxdiff
        totList = zipWith (-) maxList minList
    print $ flip mod 1000000007 . (+) (n + 1 - k + 1) . sum . take (n + 1 - k + 1) $ totList
