fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val l = readLine()!!.split(" ").map(String::toInt).sorted()

    var result = 0

    for (i in 0 until n - 2) {
        for (j in i + 1 until n - 1) {
            val max = l[i] + l[j]

            for (k in j + 1 until n) {
                if (l[k] < max) result ++
                else break
            }
        }
    }

    println(result)
}