import std.stdio, std.algorithm, std.conv, std.array;

auto readLine(T=int)() {
    return readln().split.map!(to!T).array;
}

void main() {
    int n;
    readf("%d\n", &n);
    auto L = readLine().sort;
    int ans = 0;
    foreach (ai; 0 .. n) {
        foreach (bi; ai + 1 .. n) {
            // find a list of c that satisfies c < a + b
            auto lb = L.lowerBound(L[ai] + L[bi]);
            ans += lb.length - (bi + 1);
        }
    }
    writeln(ans);
}
