object Main extends App {
 val n = readInt
 val input = readLine.split(" ").map(_.toInt).sorted
 var ans = 0
 for(i <- 0 until n) {
   for(j <- i + 1 until n) {
     var ab = input(i) + input(j)
     var result = input.takeWhile(_ < ab).length - 1 - j
     if(result > 0)  {
       ans += result
     }
   }
 }
  println(ans)  
}
