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 = n - 1 To 2 Step -1
      Dim a As Integer = l(i)
      For j As Integer = i - 1 To 1 Step -1
        Dim b As Integer = l(j)
        For k As Integer = J - 1 To 0 Step -1
          Dim c As Integer = l(k)
          If a < b + c Then 
            ans += 1
          Else
            Exit For
          End If
        Next
      Next
    Next
    Console.WriteLine(ans.ToString())
  End Sub
End Class