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))
        var pos = lowerBound(lines, j, lines.size, lines(i)+lines(j))
        val legals = pos - (j+1)
        // printf("%d:%d -> %d, %d\n", lines(i), lines(j), /*lines.deep,*/ pos, legals)
        sum += legals
      }
    }
    println(sum)
  }
  def lowerBound(ar: Array[Int], start:Int, end:Int, v:Int) :Int = {
    var ub = end
    var lb = start
    while(ub - lb > 1) {
      val mid = (ub + lb) / 2
      // printf("ub:%d, lb:%d, mid:%d\n", ub, lb, mid)
      if(ar(mid) >= v){
        //midが条件を満たせば、解の存在範囲は(lb,mid]
        ub = mid;
      } else {
        //midが条件を満たさなければ、解の存在範囲は(mid,ub]
        lb = mid;
      }
    }
    ub
  }
}

