-- | Main entry point to the application.
module Main where
 
import Control.Applicative
import Control.Monad
import Data.List
import Debug.Trace
import Text.Printf
import Data.Array

solve :: [Int] -> Int
solve ns = maximum $ zipWith (-) ns $ scanl1 min ns

-- | The main entry point.
main :: IO ()
main = do
    _ <- getLine
    ns <- concatMap (fmap (read :: String -> Int) . words) . lines <$> getContents
    -- let ns = [5,3,1,3,4,3]
    -- let ns = [1..200000]
    putStrLn $ show $ solve ns