import java.util.*

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val ln = readLine()!!.split(" ").map(String::toInt).sorted()

    var sum = 0
    for (ai in 0 until ln.size - 2) {
        for (bi in ai + 1 until ln.size - 1) {
            val ab = ln[ai] + ln[bi]
            sum += ln.binarySearch(ab, Comparator { x, y -> if (x >= y) 1 else -1 }).inv() - (bi + 1)
        }
    }
    println(sum)
}

