fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  val L = readLine()!!.split(" ").map { it.toInt() }.sorted().toTypedArray()
  var cnt = 0
  for (i in 0 until n - 2) {
    for (j in i + 1 until n - 1) {
      val index = lowerBound(L, L[i] + L[j])
      val found = index - 1 - j
      cnt += found
//      println("($i $j): ${L[i]} + ${L[j]} = ${L[i] + L[j]}, index: $index, found: $found")
    }
  }
  println(cnt)
}

fun lowerBound(array: Array<Int>, value: Int, first: Int = 0, last: Int = array.size): Int {
  var first = first - 1
  var last = last
  while (last - first > 1) {
    val middle = first + (last - first) / 2
    if (array[middle] < value) {
      first = middle
    } else {
      last = middle
    }
  }
  return last
}

fun upperBound(array: Array<Int>, value: Int, first: Int = 0, last: Int = array.size): Int {
  var first = first - 1
  var last = last
  while (last - first > 1) {
    val middle = first + (last - first) / 2
    if (array[middle] <= value) {
      first = middle
    } else {
      last = middle
    }
  }
  return last
}
