Public Class Program
  Shared Sub Main()
    Dim n As Integer = Integer.Parse(Console.ReadLine())
    Dim l As Integer() = Array.ConvertAll(Of String, Integer)(Console.ReadLine().Split(" "), AddressOf Integer.Parse)
    Array.Sort(l)
    Dim ans As Integer = 0
    For i As Integer = 0 To n - 3
      For j As Integer = i + 1 To n - 2
        Dim min As Integer = j + 1
        Dim max As Integer = n
        Do While min < max
          Dim m As Integer = (max + min) \ 2
          If l(i) + l(j) <= l(m) Then
            max = m
          Else
            min = m + 1
          End If
        Loop
        ans += min - j - 1
      Next
    Next
    Console.WriteLine(ans.ToString())
  End Sub
End Class