import scala.io.StdIn

object Main extends App {
  val n = StdIn.readLine()
  val l :Array[Int] = StdIn.readLine().split(" ").map(_.toInt)
  var ans = 0

  l.zipWithIndex.foreach {i =>
    l.drop(i._2 + 1).zipWithIndex.foreach { j =>
      l.drop(i._2 + 1 + j._2 + 1).filter(_ < (i._1 + j._1)).foreach {k =>
        if (j._1 < (k + i._1) && i._1 < (j._1 + k)) ans = ans + 1
      }
    }
  }

  println(ans)
}
  

