fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val sticks = readLine()!!.split(" ").map { it.toInt() }.sorted()
    var ans = 0
    for (left in 0..(n - 3)){
        for (right in (left + 1)..(n - 2)){
            var bottom = right
            var top = n
            while (top > bottom + 1) {
                var mid = (top + bottom) / 2
                if (sticks[mid] >= sticks[left] + sticks[right]){
                    top = mid
                } else {
                    bottom = mid
                }
            }
            ans += bottom - right
        }
    }
    println(ans)
}
