import scala.collection.mutable.ListBuffer
import scala.io.StdIn
import util.control.Breaks._

object Main extends App {
  StdIn.readLine()
  val l = StdIn.readLine().split(' ').map(_.toInt).sorted
  var res = 0
  for (x <- l.indices){
    for(y <- x+1 until l.length){
      breakable {
        for (z <- y + 1 until l.length) {
          if (l(z) >= l(y) + l(x)) break
          res += 1
        }
      }
    }
  }
  println(res)
}
