import Control.Applicative

main = do
  n <- getLine
  a <- (map read . words) <$> getLine
  putStrLn . show $ solve a
 
solve:: [Int] -> Int
solve a = ma - mi
  where
    ma = maximum a
    mi = minimum a

