import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val l = (1..n).map { sc.nextInt() }.sorted()
  val d = l.map { it.toDouble() }

  var count = 0L
  for (i in 0..n-3) {
    val a = l[i]
    for (j in i+1..n-2) {
      val b = l[j]
      val ab = a + b
      val from = j + 1
      var r = d.binarySearch(element = ab.toDouble() - 0.1, fromIndex = from, toIndex = n -1)
      if (r < 0) r = r.inv()
      if (ab > l[r]) r++
      count += Math.max(0, r-from)
    }
  }


  println(count)

}
