let () =
  let n = read_int () in
  let rec loop mb l = function
      0 -> Printf.printf "%d\n" mb
    | i ->
      let x = read_int () in
      loop
        (max mb (List.fold_left (fun acc y -> max acc (x-y)) mb l)) (x::l) (i-1)
  in
  loop min_int [] n