let () =
	Scanf.scanf "%d\n" @@ fun n ->
 let arr = Array.init n @@ fun i -> Scanf.scanf "%d\n" @@ fun d -> (i, d) in
 let (ans, _) = Array.fold_left
     (fun (ans, minN) (i, x) ->
        if i <> 0 && x < minN then (ans, x)
        else if i <> 0 && x-minN > ans then (x-minN, minN)
        else (ans, minN)) (snd arr.(1) - snd arr.(0), snd arr.(0)) arr in
  Printf.printf "%d\n" ans
