main = do
  _ <- getLine
  a <- map read . words <$> getLine
  print (max' a - min' a)

max' :: [Int] -> Int
max' xs
  | xs == [] = 0
  | otherwise = max (head xs) (max' (tail xs))

min' :: [Int] -> Int
min' xs
  | xs == [] = 100000000
  | otherwise = min (head xs) (min' (tail xs))
