import Data.List

solve :: [Int] -> Int
solve numbers = last sorted - head sorted
  where sorted = sort numbers

main :: IO ()
main = do
  _ <- getLine
  numbers <- map read . words <$> getLine
  print $ solve numbers