import java.util.*

fun main(args: Array<String>) {
    val (N) = readLine()!!.split(" ").map { it.toInt() }
    val L =readLine()!!.split(" ").map { it.toInt() }.toIntArray()
    L.sortDescending()
    var ans = 0
    for (a in 0 until N - 2){
        for (b in (a+1) until N - 1) {
            var c = bsearch(L, L[a] - L[b] + 1, b + 1, N-1) - 1
            if (L[a] + L[b] > L[c]) {
                ans += c - b
            }
        }
    }
    println(ans)
}

fun bsearch(array: IntArray, v: Int, min: Int, max: Int) : Int {
    if (min > max) return min
    val mid = min + (max - min) / 2
    return when {
        array[mid] < v -> bsearch(array, v, min, mid-1)
        array[mid] >= v -> bsearch(array, v, mid + 1, max)
        else -> Integer.MAX_VALUE
    }
}