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 (i in 0 until N) {
        for (j in i + 1 until N) {
            for (k in j + 1 until N) {
                if (LsArr[k] >= LsArr[i] + LsArr[j]) {
                    ans += k - j - 1
                    break
                }
                if (k == N - 1) {
                    ans += k - j
                }
            }
        }
    }

    println(ans)
}

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