import Control.Applicative

main = do
  getLine
  input <- map read . lines <$> getContents
  putStrLn $ show $ fst $ solve input

solve :: [Int] -> (Int,Int)
solve (a:b:[]) = (b - a, max a b)
solve (x:xs) = (max profit (maxv - x), max maxv x)
  where (profit, maxv) = solve xs

