import qualified Data.ByteString.Char8 as BS
import Data.Maybe (fromJust)
import Data.List
import Control.Monad


solve :: [Int] -> Int
solve arr =
    l - f
    where
        sorted = sort arr
        f = head sorted
        l = head (reverse sorted)

main :: IO ()
main = do
    _ <- BS.getLine
    a <- map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
    print $ solve a
