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 =>
      ans = l.drop(i._2 + 1 + j._2 + 1).filter{
        k => (k < (i._1 + j._1)) && (j._1 < (k + i._1)) && (i._1 < (j._1 + k))}.length +  ans
    }
  }

  println(ans)
}
  

