import Control.Monad
import Data.Functor

main::IO ()
main=
  do
    n <- read <$> getLine::IO Int
    list <- replicateM n (read <$> getLine)::IO [Int]
    print $ maxFrofit list


maxFrofit::Integral a=>[a]->a
maxFrofit (x:y:ys)=maxFrofit' (y:ys) x (y-x)
  where
    maxFrofit'::Integral a=>[a]->a->a->a
    maxFrofit' [a] minV maxV = maxV
    maxFrofit' (x:xs) minV maxV=maxFrofit' xs (min x minV) (max (x-minV) maxV)