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

    L.sort()


    var answer = 0
    for (i in 0 until N - 2) {
        for (j in i + 1 until N - 1) {
            val a = L[i]
            val b = L[j]
            val lower = Math.max(a - b, b - a)
            val upper = a + b
            val lowerIndex = Math.max(lowerBound(L, lower + 1), j + 1)
            val upperIndex = Math.min(lowerBound(L, upper), N)
            if (upperIndex > lowerIndex) {
                answer += (upperIndex - lowerIndex)
            }
        }
    }

    println(answer)
}

fun lowerBound(sortedList: IntArray, key: Int) : Int {
    var ng = - 1 // left
    var ok = sortedList.size  // right

    fun isOk(mid: Int) : Boolean {
        return sortedList.get(mid) >= key
    }

    while (Math.abs(ok - ng) > 1) {
        var mid = (ok + ng) / 2
        if (isOk(mid)) {
            ok = mid
        } else {
            ng = mid
        }
    }
    return ok
}