main = do
    num <- getLine
    arr <- (map read . words) <$> getLine
    let largest = foldl max (head arr) (tail arr)
    let smallest = foldl min (head arr) (tail arr)
    print $ largest - smallest