import java.util.*

fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val L = readLine()!!.split(" ").map {it.toInt()}.sorted()

    val mp = TreeMap<Int, Long>()
    mp[0] = 0L
    L.forEach {
        if (mp.isEmpty()) {
            mp[it] = 1L
        } else if (mp.lastKey() == it) {
            mp[it] = mp[it]!! + 1L
        } else {
            mp[it] = mp.lastEntry().value + 1L
        }
    }
    val keys = mp.keys.toList()

    var res = 0L

    for (i in 1 until keys.size) for (j in i + 1 until keys.size) {
        val l = Math.max(Math.abs(keys[i] - keys[j]), keys[j])
        val u = keys[i] + keys[j]

        if (u - l < 2) continue

        val a = mp.ceilingEntry(l)
        val b = mp.lowerEntry(u)

        if (b == null) continue

        val c = count(mp, keys, i)
        val d = count(mp, keys, j)

        res += (b.value - a.value) * c * d
    }

    for (i in 1 until keys.size) {
        val m = count(mp, keys, i)

        if (m >= 2) {
            val u = keys[i] * 2

            val b = mp.lowerEntry(u)

            if (b == null) continue

            res += m * (m - 1) / 2 * (b.value - m)
        }

        if (m >= 3) {
            res += m * (m - 1) * (m - 2) / 6
        }
    }

    println(res)
}

private fun count(
    mp: TreeMap<Int, Long>,
    keys: List<Int>,
    i: Int
) = mp[keys[i]]!! - mp[keys[i - 1]]!!
