main :: IO ()
main = do
    n <- fmap (read :: String -> Int) . words <$> getLine
    (putStrLn . show . solve) n

solve :: [Int] -> Int
solve (a:b:_) =
    let d = b - a
    in d * (d + 1) `div` 2 - b 