let n = stdin.ReadLine() |>  int
let l = stdin.ReadLine().Split() |> Array.map int
let sd = Array.sort l
let mutable count = 0L

for i in 2..(n-1) do
 for j in 1..(i-1) do
  let rec f low high =
   match (high - low)/2 with
   | 0 -> high
   | _ -> let mid = (high + low)/2
          if (sd.[mid] + sd.[j]) > sd.[i] then f low mid else f mid high
  if (sd.[j-1] + sd.[j]) <= sd.[i] then () else
   let sakai = f -1 (j - 1)
   count <- count + (int64 j) - (int64 sakai)

count
|>stdout.WriteLine