import java.util.Collections

fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    val Ls = readInputLine().split(" ").map { it.toInt() }.sorted()
    val LsArr = Ls.toIntArray()
    
    var ans = 0
    
    for (mid in N - 1 downTo 0) {
        for (low in mid - 1 downTo 0) {
            ans += lowerBound(Ls, LsArr[mid] + LsArr[low]) - 1 - mid
        }
    }
    
    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}

fun <T: Comparable<T>> lowerBound(list: List<T>, value: T): Int {
    return Collections.binarySearch(list, value, {x, y -> if (x >= y) 1 else -1}).inv()
}
