object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val l = new Array[Int](n)
    for (i <- 0 until n) {
      l(i) = sc.nextInt
    }

    var count = 0
    for (i <- 0 until n - 2; j <- i + 1 until n - 1; k <- j + 1 until n) {
      val a = l(i)
      val b = l(j)
      val c = l(k)
      if (a < b + c && b < a + c && c < a + b) {
        count += 1
      }
    }
    println(count)
  }
}
