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

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

auto lowerBound_(R, T)(R sorted, T value) {
    size_t left = 0;
    size_t right = sorted.length;
    while(right - left != 0) {
        auto mid = (right + left) / 2;
        if (sorted[mid] < value) {
            left = mid + 1;
        } else {
            right = mid;
        }
    }
    return sorted[0 .. right];
}

unittest {
    assert([1, 2, 3, 5].lowerBound_(4) == [1, 2, 3]);
    assert([1, 2, 3, 5].lowerBound_(3) == [1, 2]);
    assert([1, 2, 3, 5].lowerBound_(1) == []);
    assert([1, 2, 3, 5].lowerBound_(6) == [1, 2, 3, 5]);
}

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[bi + 1 .. $].lowerBound_(L[ai] + L[bi]);
            ans += lb.length;
        }
    }
    writeln(ans);
}
