import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string, core.stdc.stdlib;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!int).array;
    A.sort();
    long ans = 0;

    foreach (i; 0..N) {
        foreach (j; i+1..N) {
            auto ub = A.assumeSorted.lowerBound(A[i] + A[j]).length.to!long;
            auto lb = A.assumeSorted.lowerBound(A[j] - A[i]).length.to!long;
            lb = max(lb, j.to!long);
            if (lb >= ub) continue;
            long v = ub - lb;
            if (i >= lb && i < ub) v -= 1;
            if (j >= lb && j < ub) v -= 1;
            ans += v;

        }
    }

    ans.writeln;
}
