Scanf.scanf "%d" (fun n -> let module S = Set.Make (struct type t = int let compare = compare end) in let rec loop i acc = if i = n then S.elements acc else loop (i + 1) (Scanf.scanf " %d" (fun x -> S.add x acc)) in let a = Array.of_list (loop 0 S.empty) in let n = Array.length a in Printf.printf "%d\n" @@ if n = 1 then 0 else let rec loop i acc = if i = n then acc else loop (i + 1) (min acc (a.(i) - a.(i - 1))) in loop 1 max_int )