open System
open System.Linq;


let N=stdin.ReadLine()|>int
let L=stdin.ReadLine().Split()|>Array.map int |> Array.sort
[<EntryPoint>]
let sf argv =
    let mutable ans = 0
    for i in [0..N-3] do 
        for j in [i+1..N-2] do
            let sum =L.[i]+L.[j]
            let mutable l = -1
            let mutable r = N
            while r - l > 1 do
                let c=(l+r)/2
                match L.[c] < sum with
                | true -> l<-c
                | false -> r<-c
            ans <- ans + max 0 l-j
    printfn "%d" ans
    0 