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

    var r = 0

    (0 until n).forEach { a ->
        (a + 1 until n).forEach { b ->
            val index = binarySearch(k, k[a] + k[b])
            r += Math.max(0, (index - b))
        }
    }
    println(r)
}

fun binarySearch(list: List<Int>, k: Int): Int {
    var begin = 0
    var end = list.size - 1
    while (begin < end) {
        val mid = (begin + end) / 2 + 1
        if (list[mid] >= k) end = mid - 1
        else begin = mid
    }
    return end
}
