import kotlin.math.max

fun main(args: Array<String>) {
    val n = readInt()
    val L = readIntList().sorted()
    //println(L)

    var ans = 0
    for (b in 0 until n) {
        for (a in 0 until b) {
            val ab = L[a] + L[b]
            var r =
                L.binarySearch(element = ab, comparator = lower).inv()
            //if (r == -1) r = n
            val l = b + 1
            //println("a=$a b=$b ab=$ab l=$l r=$r")
            ans += max(0, r - l)
        }
    }
    println(ans)
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

val lower = Comparator { x: Int, y: Int -> if (x >= y) 1 else -1 }