#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin("nrtri.in");
ofstream fout("nrtri.out");
const int NMAX = 800;
int v[NMAX + 5];
int bs(int i, int j, int n)
{
    int st = j + 1, dr = n - 1, mij, rez = -1, x = v[i] + v[j];
    while (st <= dr)
    {
        mij = (st + dr) / 2;
        if (x < v[mij])
        {
            dr = mij - 1;
        }
        else
        {
            rez = mij;
            st = mij + 1;
        }
    }
    return rez;
}
int main()
{
    int n, i, j, k, s = 0;
    fin >> n;
    for (i = 0; i < n; ++i)
    {
        fin >> v[i];
    }
    sort(v, v + n);
    for(i = 0; i < n - 2 ; ++i)
        for(j = i + 1 ; j < n - 1; ++j)
        {
            k = bs(i, j, n);
            if (k != -1)
            {
                s += k - j;
            }
        }
    fout << s;
    return 0;
}