(*
ocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out
*)
open Batteries

let n = Scanf.sscanf (read_line ()) "%d" ( fun n -> n)
let nlst = Str.split (Str.regexp " ") (read_line ())
           |> List.map int_of_string

let check lst =
        match lst with
                | first :: second :: third :: [] -> 
                        if first + second > third &&
                           second + third > first &&
                           third + first > second then
                                true
                        else
                                false
                | [] -> false
                | first :: rest -> false 

let rec f lst ac =
        if lst = [] then
                if check ac then
                        1
                else
                        0
        else
                match lst with
                          [] -> 0
                        | first :: rest -> 
                                if not (List.exists (fun elmnt -> elmnt = first) ac) then
                                        (f rest (first :: ac)) + (f rest ac)
                                else
                                        f rest ac

let () = Printf.printf "%d\n" (f nlst [])
