import java.util.Scanner

val sc = Scanner(System.`in`)

fun main(args : Array<String>) {
    val n = sc.nextInt()
    val ll = listOfInt(n).sorted().toIntArray()

    var count = 0
    for(i in 0 until ll.size-2) {
        for(j in i+1 until ll.size-1) {
            for(k in j+1 until ll.size) {
                if (ll[i] + ll[j] > ll[k]) {
                    count++
                } else {
                    break
                }
            }
        }
    }

    println(count)
}

fun listOfInt(n: Int) = (1..n).map { sc.nextInt() }