import Data.List

solve :: [Int] -> Int
solve xs = f xs
    where
        f :: [Int] -> Int
        f []     = 0
        f [y]    = 0
        f (y:ys) = max (maximum $ map (`sub` y) ys) (f ys)
        sub      = (-)

main :: IO ()
main = getContents >>= print . solve . map read . drop 1 . lines