import           Control.Applicative
import           Control.Monad
import           Data.List

main = do
    n <- readLn
    r <- map read <$> replicateM n getLine :: IO [Int]
    print . snd . foldl' f (head r, -9999999999) $ tail r
  where
    f :: (Int, Int) -> Int -> (Int, Int)
    f (minv, maxv) r =
        let maxv' = max maxv (r - minv)
            minv' = min minv r
        in (minv', maxv')

