{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.ByteString.Char8 as BC
import           Data.Maybe            (fromJust)

main :: IO ()
main = do
  n <- readLn
  as <- map readInt . BC.words <$> BC.getLine
  print $ solve n as

solve :: Int -> [Int] -> Int
solve n as = maximum [abs (a1 - a2) | a1 <- as, a2 <- as]

readInt :: BC.ByteString -> Int
readInt = fst . fromJust . BC.readInt
