import scala.math.min
import java.util.Arrays.binarySearch
object Main {
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val lines = Array.fill(n)(sc.nextInt).sorted
    var sum = 0
    for(i <- 0 to lines.size-3) {
      for(j <- i+1 to lines.size-2) {
        var pos = binarySearch(lines, j+1, lines.size, lines(i)+lines(j))
        if (pos < 0) pos = ~pos // 挿入点
        val legals = pos - (j+1)
        //(pos match {
          //case 0 => 0// 辺全滅
          //case v => v-(j+1) // 開始地点～挿入点までの要素がOK
        //})
        //printf("%d:%d |%s| -> %d, %d\n", lines(i), lines(j), lines.deep, pos, legals)
        sum += legals
      }
    }
    println(sum)
  }
}
