let () =
  let n = read_int () in
  let rec read l = function
      0 -> List.rev l
    | i -> read (read_int () :: l) (i-1)
  in
  let m,d,lst = match read [] n with
      a::b::l when a < b -> a,b-a,l
    | a::b::l -> b,a-b,l
    | _ -> 0,0,[]in
  let _,md = List.fold_left
      (fun acc v ->
         match acc with
           m,md -> let d = v-m in
           (if v < m then v else m), (if d > md then d else md))
      (m,d)
      lst in
  Printf.printf "%d\n" md