#include <iostream>
#include <algorithm>
#include <fstream>
using namespace std;
ifstream f("nrtri.in");
ofstream g("nrtri.out");
int v[1001], n;
int cautbin(int x)
{
    int p = 1, u = n, poz = -1;
    while(p <= u)
    {
        int m = (p + u) / 2;
        if(x >= v[m])
        {
            poz = m;
            p = m + 1;
        }
        else
            u = m - 1;
    }
    return poz;
}
int main()
{
    int nr = 0;
    f >> n;
    for(int i = 1; i <= n; i++)
        f >> v[i];
    sort(v + 1, v + n + 1);
    for(int i = 1; i <= n - 2; i++)
        for(int j = i + 1; j <= n - 1; j++)
        {
            int poz = cautbin(v[i] + v[j]);
            if(poz != -1)
                nr += poz - j;
        }
    g << nr << endl;
    return 0;
}