fun main(args: Array<String>){
    val N = nextInt()
    val L = listOfInt().sorted()
    val D = L.map { it.toDouble()}
    var ans = 0L
    for (a in 0 until N-2) {
        for (b in a+1 until N-1) {
            val ab = (L[a] + L[b]).toDouble()
            val l = b + 1
            var r = D.binarySearch(element = ab - 0.1, fromIndex = l, toIndex = N - 1)
            if (r < 0) r = r.inv()
            if (ab > L[r]) r++
            val c = Math.max(0, r - l)
            ans += c
        }
    }
    println(ans)
}
fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }