import qualified Data.ByteString.Char8 as B
import Data.Maybe
import Control.Monad
import Data.List

main :: IO ()
main = do
    n <- read <$> getLine :: IO Int
    ns <- sort . map (fst . fromJust . B.readInt) . B.words <$> B.getLine :: IO [Int]
    -- print $ ns
    print $ last ns - head ns