find'::Eq a=>a->[] a->Int
find' x [] = 0
find' x (y:ys) =
  if y == x
    then 0
    else 1 + find' x ys
split::Char->String->[] String
split x [] = []
split x ys = take n ys : (split x (drop (n+1) ys))
  where
    n = find' x ys
toInt::String->Int
toInt = read
maxProf::Int->[] Int->Int
maxProf mini (x:[]) = x - mini
maxProf mini (x:xs) =
  max (x - mini) (maxProf (min x mini) xs)
main = do
  getLine
  getContents >>=
    print.(maxProf (2*10^9::Int)).(map toInt).(split '\n')
