let () =
    let split s =
        let rec loop i cur flag acc =
            if i = String.length s then ( if flag then cur :: acc else acc) else (
                match flag, s.[i] with
                | true,  ' ' -> loop (i + 1) "" false (cur :: acc)
                | false, ' ' -> loop (i + 1) "" false acc
                | true,  v   -> loop (i + 1) (Printf.sprintf "%s%c" cur v) true acc
                | false, v   -> loop (i + 1) (Printf.sprintf "%s%c" cur v) true acc
            )
        in
        List.map int_of_string (List.rev (loop 0 "" false []))
    in
    let main () =
        let n = int_of_string (read_line ()) in
        let l = split (read_line ()) in
        let l = Array.of_list l in
        Array.sort compare l;
        let hist = Array.make 1001 0 in
        for i = 0 to n - 1 do hist.(l.(i)) <- hist.(l.(i)) + 1 done;
        let accsum = Array.make 1001 0 in
        let rec loop i acc =
            if i < 1001 then (
                let acc = acc + hist.(i) in
                accsum.(i) <- acc;
                loop (i + 1) acc
            )
        in
        loop 0 0;

        let rec loop_i i acc =
            let rec loop_j j acc =
                if j = n then acc else
                    let v = accsum.(min 1000 (l.(i) + l.(j) - 1)) - accsum.(l.(j) - 1) - 1 in
                    let v = if l.(i) = l.(j) then v - 1 else v in
                    loop_j (j + 1) (acc + v)
            in
            if i = n - 1 then acc else loop_i (i + 1) (loop_j (i + 1) acc)
        in
        let r = loop_i 0 0 in
        Printf.printf "%d\n" r
    in
    main ()