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

    for (ai in l.indices) {
        for (bi in l.indices) {
            if(ai == bi) continue
            // a-b < c
            // -a+b < c
            // a+b > c
            //System.err.println("ai=$ai, bi=$bi")
            val if1 = l.upperBound(l[ai]-l[bi])
            //System.err.println("if1=$if1")
            val if2 = l.upperBound(-l[ai]+l[bi])
            //System.err.println("if2=$if2")
            val underIf = Math.max(if1, if2)
            val upperIf = l.lowerBound(l[ai]+l[bi])
            //System.err.println("if3=$upperIf")
            var up = Math.max(0, upperIf - underIf)
            if(ai in underIf until upperIf) up--
            if(bi in underIf until upperIf) up--
            //System.err.println("up:$up")
            ans += up
        }
    }

    //System.err.println(ans)
    println(ans / 6)
}

/**
 * elementをキーとして、キー以上の要素の中で最も小さい位置のインデックスを返す。
 * 検索範囲は[fromIndex, toIndex)
 *
 * @param fromIndex この位置を含む範囲
 * @param toIndex この位置を含まない範囲
 * @return 0-indexedなインデックス
 */
fun <T : Comparable<T>> List<T>.lowerBound(
    element: T,
    fromIndex: Int = 0,
    toIndex: Int = size
): Int {
    rangeCheck(size, fromIndex, toIndex)

    var low = fromIndex - 1
    var high = toIndex

    while (high - low > 1) {
        val mid = low + (high - low) / 2
        val midVal = get(mid)
        if (midVal < element) low = mid
        else high = mid
    }

    return high
}

/**
 * elementをキーとして、キーより大きい要素の中で最も小さい位置のインデックスを返す。
 * 検索範囲は[fromIndex, toIndex)
 *
 * @param fromIndex この位置を含む範囲
 * @param toIndex この位置を含まない範囲
 * @return 0-indexedなインデックス
 */
fun <T : Comparable<T>> List<T>.upperBound(
    element: T,
    fromIndex: Int = 0,
    toIndex: Int = size
): Int {
    rangeCheck(size, fromIndex, toIndex)

    var low = fromIndex - 1
    var high = toIndex

    while (high - low > 1) {
        val mid = low + (high - low) / 2
        val midVal = get(mid)
        if (midVal <= element) low = mid
        else high = mid
    }

    return high
}

/**
 * Checks that `from` and `to` are in
 * the range of [0..size] and throws an appropriate exception, if they aren't.
 */
private fun rangeCheck(size: Int, fromIndex: Int, toIndex: Int) {
    when {
        fromIndex > toIndex -> throw IllegalArgumentException("fromIndex ($fromIndex) is greater than toIndex ($toIndex).")
        fromIndex < 0 -> throw IndexOutOfBoundsException("fromIndex ($fromIndex) is less than zero.")
        toIndex > size -> throw IndexOutOfBoundsException("toIndex ($toIndex) is greater than size ($size).")
    }
}