fun main(args: Array<String>){
  val n = readLine()!!.toInt()
  val lStr = readLine()!!.split(" ")
  val l = IntArray(n){ lStr[it].toInt() }
  l.sort()

  var result = 0
  for( i in 0 until n-2 ) for( j in i+1 until n-1 ) for( k in j+1 until n ){
    if( l[i] + l[j] <= l[k] )
      break
    result++
  }

  println(result)
}
