fun main(args: Array<String>) {
    solve(java.util.Scanner(System.`in`))
}

fun <A> List<Comparable<A>>.upperBoundOf(target: A): Int {
    var l = -1
    var r = this.count()
    while (l + 1 < r) {
        val mid = (l + r) / 2
        if (this[mid] > target) {
            r = mid
        } else {
            l = mid
        }
    }
    return r
}

fun solve(sc: java.util.Scanner) {
    val N = sc.nextInt()
    val L = Array(N) { sc.nextLong() }.sorted()

    var result = 0L
    for (i in 2 until N) {
        val a = L[i]
        for (j in 1 until i) {
            val b = L[j]
            val ci = j - L.upperBoundOf(a - b)
            if (ci > 0) result += ci
        }
    }
    println(result)
}
