import java.io.{BufferedReader, InputStreamReader}

import scala.annotation.tailrec

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val n = in.readLine().toInt
    val ls = in.readLine().split("\\s+").map(_.toInt).sorted

    def countWhile(index: Int, cond: Int => Boolean): Int = {
      @tailrec
      def binarySearch(sIndex: Int, eIndex: Int): Option[Int] = {
        if (sIndex > eIndex) {
          None
        } else {
          val index = (eIndex + sIndex) / 2
          if (!cond(ls(index))) {
            binarySearch(sIndex, index - 1)
          } else {
            if (index == ls.length - 1) {
              Some(index)
            } else {
              if (!cond(ls(index + 1))) {
                Some(index)
              } else {
                binarySearch(index + 1, eIndex)
              }
            }
          }
        }
      }

      binarySearch(index, ls.length - 1) match {
        case Some(i) => i - index + 1
        case None => 0
      }
    }

    System.out.println(
      (for {
        ai <- 0 until ls.length - 2
        a = ls(ai)
        bi <- (ai + 1) until ls.length - 1
        b = ls(bi)
        apb = a + b
        amb = a - b
      } yield {
        countWhile(bi + 1, c => c < apb && amb < c && 0 < c + amb)
      }).sum
    )
  }
}
