import java.util.*

fun main(args : Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val array = IntArray(n)
    for (i in 0..n-1) {
        array[i] = scanner.nextInt()
    }
    val sortedArray = array.sortedArrayDescending()

    var sum = 0
    var preMax = 0
    var preMiddle = 0
    var preMin = 0

    loop1@for (i in 0..n-3) {
        val max = sortedArray[i]
        val pmax = preMax
        preMax = max
//        if (pmax == max) continue@loop1
        val half = max / 2
        preMiddle = 0

        loop2@for (j in i+1..n-2) {
            val middle = sortedArray[j]
            val pmiddle = preMiddle
            preMiddle = middle
//            if (pmiddle == middle) continue@loop2
            if (middle <= half) break@loop2
            preMin = 0

            loop3@for (k in j+1..n-1) {
                val min = sortedArray[k]
                val pmin = preMin
                preMin = min
//                if (pmin == min) continue@loop3

                if (max < middle + min) {
                    sum += 1
                }
            }
        }
    }

    println(sum)
}