fun main(args: Array<String>) {
    val n = readInteger()
//    val lList = readIntegerList().sorted().mapIndexed { index, i -> Pair(i, index) }
    val lList = readIntegerList().sorted()

    var ans = 0L
    for (i in lList.indices) {
        for (j in (i + 1) until lList.size) {
            val a = lList[i]
            val b = lList[j]
            val cCount = Math.max(0, lowerBound(lList, a + b) - j - 1)
            ans += cCount
        }
    }

    println(ans)
}

fun <T : Comparable<T>>lowerBound(list: List<T>, target: T): Int {
    var left = -1
    var right = list.size
    while (right - left > 1) {
        val mid = (right + left) / 2
        if (target <= list[mid])  {
            right = mid
        } else {
            left = mid
        }
    }

    return right
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
