import Data.List

-- max: ?????????????????§???, x:??§?????????????????????list
search :: Int -> [(Int,Int)] -> [Int]
search _ [] = []
search cur_max x =
  let (hn,hv) = head x
      (ln,lv) = last x
      new_max = max cur_max (hv-lv)
  in
    if (hv-lv) < cur_max
    then []
    else
      if ln < hn -- ok.found
      then (hv-lv):(search new_max $ init x)
      else search cur_max $ tail x

ans x = 
    let (x0:x1:_) = x
        init_max  = x1 - x0
        s = sortBy (\(na,va) (nb,vb) -> compare vb va) $ zip [1..] x
        v = (init_max):(search init_max s)
    in
      maximum v

main = do
    n <- getLine
    c <- getContents
    let i = map read $ lines c :: [Int]
        o = ans i
        z = zip [1..] i
        s = sortBy (\(na,va) (nb,vb) -> compare va vb) z
    print o