fun main(args: Array<String>){
    val N = nextInt()
    val L = listOfInt().sorted()
    var ans = 0L
    for (i in 0 until N-2) {
        for (j in i+1 until N-1) {
            for (k in j+1 until N) {
                if (L[i] + L[j] <= L[k]) break
                ans++
            }
        }
    }
    println(ans)
}
fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toLong() }
