fun main(args: Array<String>) = yorukatsu21c()

fun yorukatsu21c() {
    val n = readLine()!!.toInt()
    val lList = readLine()!!.split(' ').map { it.toLong() }.sorted().toLongArray()

    var answer = 0L

    for (i in 0 until n) {
        for (j in i + 1 until n) {
            val ci = lowerBound(lList, lList[i] + lList[j])
            if (ci > j) answer += ci - j - 1
        }
    }

    println(answer)
}

private fun lowerBound(list: LongArray, key: Long): Int {
    var ng = -1
    var ok = list.size

    while (ok - ng > 1) {
        val mid = (ok + ng) / 2
        if (list[mid] >= key) ok = mid else ng = mid
    }
    return ok
}
