import java.io.{BufferedReader, InputStreamReader}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val n = in.readLine().toInt
    val ls = in.readLine().split("\\s+").map(_.toInt)

    System.out.println(
      (for {
        ai <- 0 until ls.length - 2
        bi <- (ai + 1) until ls.length - 1
        ci <- (bi + 1) until ls.length
      } yield {
        val (a, b, c) = (ls(ai), ls(bi), ls(ci))

        a < b + c && b < c + a && c < a + b
      }).count(b => b)
    )
  }
}
