Scanf.scanf "%d" (fun n -> let t = let rec loop i acc = if i = n then acc else loop (i + 1) (Scanf.scanf " %d" (fun d -> acc lor (1 lsl d))) in loop 0 0 in let rec loop i acc = let check o = t land (1 lsl ((i + o) mod 12)) = 0 in if i = 12 then acc else let acc = if check 1 && check 3 && check 6 && check 8 && check 10 then i :: acc else acc in loop (i + 1) acc in Printf.printf "%d\n" @@ match loop 0 [] with | [ a ] -> a | _ -> -1 )