[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

type Array with
    static member private _BinarySearch<'T when 'T: comparison>
        (comp, array: 'T [], first: Int32, last: Int32, value: 'T) =
        let rec loop left right =
            if left > right then
                left
            else
                let mid = left + ((right - left) >>> 1)
                if comp array.[mid] value then
                    loop (mid + 1) right
                else
                    loop left (mid - 1)
        loop first (last - 1)

    static member LowerBound<'T when 'T: comparison>
        (array: 'T [], first: Int32, last: Int32, value: 'T) =
        Array._BinarySearch((<), array, first, last, value)

    static member UpperBound<'T when 'T: comparison>
        (array: 'T [], first: Int32, last: Int32, value: 'T) =
        Array._BinarySearch((<=), array, first, last, value)

[<EntryPoint>]
let main _ =
    let N = read int
    let LS = reada int |> Array.sort

    let mutable ans = 0
    for i in [N-1 .. -1 .. 2] do
        for j in [i-1 .. -1 .. 1] do
            let high = LS.[i]
            let mid = LS.[j]
            let bound = Array.UpperBound(LS, 0, LS.Length, (high - mid))
            let lows = max 0 (j - bound)
            ans <- ans + lows

    printfn "%i" ans
    0