f n k = maxSum - minSum + 1
  where minSum = (k - 1) * k `div` 2
        maxSum = (n - k + 1 + n) * k `div` 2

main = do
    [n, k] <- map read . words <$> getLine :: IO [Int]
    let m = 10 ^ 9 + 7
    print $ foldl (\acc -> \i -> (acc + f n i) `mod` m) 0 [k..n + 1]
