import qualified Data.ByteString.Char8 as C
import Data.Maybe 
  ( fromJust )

main = do
  _  <- getLine
  as <- map (fst . fromJust . C.readInt) . C.words <$> C.getLine 
  print $ uncurry (-) $ maxMin as

maxMin :: [Int] -> (Int, Int)
maxMin = (,) <$> maximum <*> minimum