let () =
  let n = read_int () in
  let rec loop mv md = function
      0 -> md
    | i ->
      let v = read_int () in
      let d = v - mv in
      loop (if v < mv then v else mv) (if d > md then d else md) (i-1)
  in
  let x = loop (read_int ()) min_int (n-1) in
  Printf.printf "%d\n" x