let () =
  let m = Scanf.scanf "%d\n" (fun x -> x) in
  let minv = ref (Scanf.scanf "%d\n" (fun x -> x)) in
  let n, d = Scanf.scanf "%d\n" (fun x -> x , x - !minv) in
  let maxv = ref d in
  if n < !minv then minv := n else ();
  for i = 1 to m - 2 do
    let num, diff = Scanf.scanf "%d\n" (fun x -> x, x - !minv) in
    if !maxv < diff then maxv := diff else ();
    if num < !minv then minv := num else ();
  done;
  Printf.printf "%d\n" !maxv;;
