object Main extends App {
 val n = readInt
 val input = readLine.split(" ").map(_.toInt)
 var count = 0
 def isVaild(a:Int, b:Int, c:Int):Boolean = a < (b + c) && b < (a + c) && c < (a + b)
 for{i <- 0 until n - 2
     j <- i + 1 until n - 1
     k <- j + 1 until n
    if (isVaild(input(i), input(j), input(k)))} {
      count += 1 
  }
  println(count)  
  
}