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
        a = ls(ai)
        bi <- (ai + 1) until ls.length - 1
        b = ls(bi)
        ab = a + b
        ci <- (bi + 1) until ls.length
        c = ls(ci)
      } yield {
        c < ab && a < b + c && b < c + a
      }).count(b => b)
    )
  }
}
