import java.util.Collections

import scala.io.StdIn

object Main {
  def main(args: Array[String]) = {
    val N = StdIn.readLine.toInt
    val L = StdIn.readLine.split(" ").map(l => l.toInt).sorted
    var ans = 0
    for (i <- 0 until N-2) {
      for (j <- i + 1 until N-1) {
        var low = j
        var high = N
        while(high - low > 1) {
          val mid = (high + low) / 2
          if (L(mid) < L(i) + L(j)) {
            low = mid
          } else {
            high = mid
          }
        }
        ans += low - j
      }
    }

    println(ans)
  }
}
