import Control.Monad

solver :: [Int] -> Int
solver xs = maximum xs - minimum xs

main :: IO()
main = do
    _ <- getLine
    line <- (map (read :: String -> Int)) . words <$> getLine
    print $ solver line
