[<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

let upperBound (array: 'T []) first last value =
    let rec loop left right =
        if left > right then
            left
        else
            let mid = left + ((right - left) >>> 1)
            if array.[mid] <= value then
                loop (mid + 1) right
            else
                loop left (mid - 1)
    loop first (last - 1)

[<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 = upperBound LS 0 LS.Length (high - mid)
            let lows = max 0 (j - bound)
            ans <- ans + lows

    Console.WriteLine(ans)
    0