import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Queue, PriorityQueue}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)


  val N = in.next().toInt
  val _L = new Array[Int](N+1)
  for (i <- 1 to N)
    _L(i) = in.next().toInt


  val L = _L.sorted



  //
  def check(i: Int, j: Int, k: Int): Boolean =
    L(k) < L(i) + L(j)


  // 条件を満たす最大の値を返す
  def binarySearch(min: Int, max: Int, i: Int, j: Int): Int = {
    val mid: Int = (max + min) / 2
      (max - min) match{
      case 0 | 1 =>
        check(i,j,max) match{
          case true  => max
          case false => min
        }
      case _ =>
        (check(i,j,mid)) match{
          case true  => binarySearch(mid, max,i,j)
          case false => binarySearch(min, mid,i,j)
        }
    }
  }
  var ans = 0L

  for (i <- 1 to N-2) {
    for (j <- i+1 to N-1) {
      val k = binarySearch(j+1, N, i, j)

      if(check(i, j, k)) {

        ans += k-j
      }
    }
  }

  println(ans)
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}
