import java.lang.Math

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

    var cnt = 0
    for (i in 0 until n-2) {
        for (k in i+1 until n-1) {
            var ok = -1
            var ng = n
            while (Math.abs(ok - ng) > 1) {
                var mid = (ok + ng) / 2
                if (l[mid] > l[i] - l[k]) ok = mid
                else ng = mid
            }

            cnt += if (ok > k) ok - k else 0
        }
    }

    println(cnt)
}
