#include <fstream>
#include <algorithm>

using namespace std;

int const L = 9;
int v[801];
int n;

ifstream fin("nrtri.in");
ofstream fout("nrtri.out");

int cautbin ( int x )
{
    int r = 0, pas = 1<<L;
    while ( pas!= 0 )
    {
        if ( r + pas < n && v[r + pas] <= x )
        {
            r += pas;
        }
        pas /= 2;
    }
    return r;
}

int main()
{
    int k, rez = 0;
    fin >> n;
    for ( int i = 0; i < n; i++ )
    {
        fin >> v[i];
    }
    sort ( v, v + n );
    for ( int i = 0; i < n - 2; i++ )
    {
        for ( int j = i + 1; j < n - 1; j++ )
        {
            k = cautbin ( v[i] + v[j] );
            if ( k > j)
            {
                rez += k - j;
            }
        }
    }
    fout << rez;
    fin.close();
    fout.close();
    return 0;
}