"use strict";

const upperBound = (arr, n) => {
    let first = 0, last = arr.length - 1, middle;
    while (first <= last) {
        middle = 0 | (first + last) / 2;
        if (arr[middle] <= n) first = middle + 1;
        else last = middle - 1;
    }
    return first;
}

const lowerBound = (arr, n) => {
    let first = 0, last = arr.length - 1, middle;
    while (first <= last) {
        middle = 0 | (first + last) / 2;
        if (arr[middle] < n) first = middle + 1;
        else last = middle - 1;
    }
    return first;
}

const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const L = arg[1].split(" ").map(n=>parseInt(n)).sort((a,b)=>a-b);
    
    // console.log(L);
    let answer = 0;
    
    for(let i=0; i<N; i++) {
        for(let j=i+1; j<N; j++) {
            const b = L[i];
            const c = L[j];
            
            //const min = lowerBound(L.slice(j+1), Math.abs(b-c));
            const max = lowerBound(L, b + c);
            
            // console.log(b);
            // console.log(c);
            
            //console.log("min:" + min);
            //console.log(N - max);
            // console.log("max:" + max);
            answer += max - (j + 1);
        }
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));