fun main(args: Array<String>) {

    val n = readLine()!!.toInt()
    val ds = readLine()!!.split(" ").take(n).map { it.toInt() }.sorted().toIntArray()

    var count = 0
    for (ai in (0 until ds.size - 2)) {
        for (bi in (ai + 1 until ds.size - 1)) {
            for (ci in (bi + 1 until ds.size)) {
                if (ds[ci] < ds[ai] + ds[bi]) {
                    count++
                } else {
                    break
                }

            }
        }
    }

    print(count)
}
