solve :: [Int] -> Mint
solve [n, k] = sum $ map f [k..n+1] where
  f k = su (n-k+1) n - su 0 (k-1) + 1
  su a b = toEnum $ (a+b) * (b-a+1) `div` 2

main = getLine >>= print.solve.map read.words

modulus = 10^9 + 7
newtype Mint = M Int
instance Num Mint where
  (M a) + (M b)
    | a + b < modulus = M $ a + b
    | otherwise = M $ a + b - modulus
  (M a) - (M b)
    | a - b < 0 = M $ modulus + a - b
    | otherwise = M $ a - b
  (M a) * (M b) = toEnum $ a * b
  fromInteger = toEnum . fromInteger
  abs = id
  signum = const $ M 1
instance Enum Mint where
  fromEnum (M a) = a
  toEnum a = M $ mod a modulus
instance Show Mint where
  show = show . fromEnum