function compareNumbers(a, b) { //for sort
    return a-b;
}

function Main(arg) {
 
    var N = arg.split("\n")[0]-0;
    var L = arg.split("\n")[1].split(" ").map(v=>v-0);
 
    var ans = 0;

    var a, b, c;
    L.sort(compareNumbers);
    for (var i = 0; i < N - 2; i++){
        a = L[i];
        for (var j = i+1; j < N - 1; j++){
            b = L[j];
            for (var t = j+1; t < N; t++){
                c = L[t];
                if (a + b <= c) break;
                ans++;
            }
        }
    }


    console.log(ans)

    return;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));