Scanf.scanf "%d" (fun n ->
    let l = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in
    Array.sort compare l;

    let rec loop_a1 a1 acc =
        let rec loop_a2 a2 acc =
            let rec loop_a3 a3 acc =
                if a3 = n then acc else
                    loop_a3 (a3 + 1) (if l.(a1) <> l.(a2) && l.(a2) <> l.(a3) && l.(a1) + l.(a2) > l.(a3) then acc + 1 else acc)
            in
            if a2 = n then acc else loop_a2 (a2 + 1) (loop_a3 (a2 + 1) acc)
        in
        if a1 = n then acc else loop_a1 (a1 + 1) (loop_a2 (a1 + 1) acc)
    in
    loop_a1 0 0 |> Printf.printf "%d\n"
)