object Main extends App {
 val n = readInt
 val input = readLine.split(" ").map(_.toInt).sorted.reverse
 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) {
     val a = input(i)
     val b = input(i + 1)
     val c = input(i + 2)
     if(a < b + c)
       for(j <- i + 1 until n - 1)
         for(k <- j + 1 until n)
           if (isVaild(input(i), input(j), input(k))) {
             count += 1 
           }
 }
  println(count)  
  
}