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).sorted

    def countWhile(index: Int, cond: Int => Boolean): Int = {
      def inner(count: Int, index: Int): Int = {
        if (ls.length <= index) {
          count
        } else if (cond(ls(index))) {
          inner(count + 1, index + 1)
        } else {
          count
        }
      }

      inner(0, index)
    }

    System.out.println(
      (for {
        ai <- 0 until ls.length - 2
        a = ls(ai)
        bi <- (ai + 1) until ls.length - 1
        b = ls(bi)
        apb = a + b
        amb = a - b
      } yield {
        countWhile(bi + 1, c => c < apb && amb < c && 0 < c + amb)
      }).sum
    )
  }
}
