Scanf.scanf "%d" (fun n -> let rec gcd a b = if b = 0 then a else gcd b (a mod b) in let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in let rec loop_i i acc = let rec loop_j j acc = let rec loop_k k g acc = if k = n then acc else let acc = if gcd g a.(k) = 1 then acc + 1 else acc in loop_k (k + 1) g acc in if j = n then acc else loop_j (j + 1) (loop_k (j + 1) (gcd a.(i) a.(j)) acc) in if i = n then acc else loop_i (i + 1) (loop_j (i + 1) acc) in loop_i 0 0 |> Printf.printf "%d\n" )