import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (n : k : _) <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  print $ (n - k + 2) * (n * n + n + 6 - 2 * k * k + k * (n + 2)) `div` 6 `mod` modulus

modulus :: Int
modulus = 1000000007

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
