_bound = (arr, value, compare) => {
    var first = 0
    var last = arr.length - 1
    var mid
    while(first < last) {
        mid = first + Math.floor((last - first) / 2)
        if (compare(arr[mid], value)) {
            first = mid + 1
        } else {
            last = mid
        }
    }
    return last
}

_inner_bound = (arr, value) => {
    var compare = (a, b) => a < b
    return _bound(arr, value, compare)
}

input = require('fs').readFileSync('/dev/stdin', 'utf8')
lines = input.split('\n')
N = lines.shift() * 1
L = lines.shift().split(' ')
L.sort((a,b) => a-b)
sum = 0
for (i=L.length - 1; i >= 2; i--) {
    for (j=i-1; j >= 1; j--) {
        k = _inner_bound(L, L[i] - L[j] + 1)
        if (j > k) {
            sum += j - k
        }
    }
}
console.log(sum)