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

void main() {
    int n;
    readf("%d\n", &n);
    auto ls = readln().split.map!(to!int).array.sort!"a > b";

    size_t count = 0;
    foreach (ai; 0 .. n - 2) {
        if (ls[ai] >= ls[ai+1] + ls[ai+2]) continue;
        foreach (bi; ai + 1 ..n - 1) {
            if (ls[bi] >= ls[bi+1] + ls[ai]) continue;
            foreach (ci; bi + 1 .. n) {
                if (ls[ai] < ls[bi] + ls[ci] &&
                    ls[bi] < ls[ci] + ls[ai] &&
                    ls[ci] < ls[ai] + ls[bi])
                {
                    ++count;
                } else break;
            }
        }
    }
    writeln(count);
}
