function Main(input) {
    var N = parseInt(input[0], 10);
    var L = input.slice(1).map(n => parseInt(n, 10));

    var result = 0;
    var asc = L.sort((a, b) => a - b);
    var ab = 0;
    var cache = 0;

    for (var a = 0; a < N - 2; a++) {
        for (var b = a + 1; b < N - 1; b++) {
            ab = asc[a] + asc[b];
            for (var c = cache ? cache : b + 1; c < N; c++) {
                if (asc[c] < ab) {
                    result++;
                } else {
                    c += 2000;
                }
            }
        }
    }

    console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));