import Data.List

solve :: [Int] -> Int
solve (n:xs) = maximum $ [(xs !! j) - (xs !! i) | i <- is, j <- is, i < j]
    where is = [0 .. n - 1]

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