fun main() {
    val n = nextInt()
    val l = nextIntList().sorted()
    var cnt = 0

    for (b in 0 until n) {
        for (a in 0 until b) {
            var idx = l.binarySearch(element = l[a] + l[b], comparator = Comparator { a, b -> if (a >= b) 1 else -1 }).inv()
            cnt += Math.max(0, idx-b-1)
        }
    }

    println(cnt)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map { it.toInt() }
fun nextLongList() = nextList().map { it.toLong() }
fun nextDoubleList() = nextList().map { it.toDouble() }
