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 inner(count: Int, index: Int): Int = {
        if (ls.length <= index) {
          count
        } else if (cond(ls(index))) {
          inner(count + 1, index + 1)
        } else {
          count
        }
      }

      inner(0, index)
    }

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