import scala.math.min
object Main {
  def main(args:Array[String]) = {
    
    // printf("%d\n", b(Array(218, 233, 389, 645, 704, 728), 2, 5, v => v < 218+233))
    // System.exit(0)

    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-1) {
      for(j <- i+1 to lines.size-2) {
        val r  = b(lines, j+1, lines.size-1, v => v < lines(i)+lines(j))
        sum += r
        // printf("%d:%d -> %d\n", lines(i), lines(j), r)
      }
    }
    println(sum)
  }
  def b(ar:Array[Int], start:Int, end:Int, f: Int=> Boolean): Int = {
    // @scala.annotation.tailrec
    def b_(start2 :Int, end2 :Int): Int = {
      // printf("%d:%d\n", start2, end2)
      // 要素が残り1つ
      if (start2 == end2) {
        if (f(ar(start2))) {
          return end + 1 - start // 右端に到達
        } else {
          return 0               // 左端に到達
        }
      }
      // 要素が残り2つ
      if (start2+1 == end2) {
        return (f(ar(start2)), f(ar(end2))) match {
          case (true, false)  => end2 - start
          case (_,    _)      => b_(start2, start2)
        }
      }
      // 要素が3つ以上
      var middle = (start2 + end2) / 2
      return (f(ar(middle)), f(ar(middle+1))) match {
        case (true, false)  => middle+1 - start
        case (true, true)   => b_(middle, end2)
        case (false, false) => b_(start2, middle)
      }
    }
    b_(start, end)
  }
}
