#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin("nrtri.in");
ofstream fout("nrtri.out");
int main()
{
    int n,i,j,mij,t=0,s,d;
    fin>>n;
    int v[n+1];
    for(i=1; i<=n; i++)
    {
        fin>>v[i];
    }
    sort(v+1,v+n+1);
    for ( i=1; i<=n; i++ )
        for ( j=i+1; j<n; j++ )
        {
            s = j + 1;
            d = n;
            while ( s <= d )
            {
                mij = ( s + d )/2;
                if ( v[i] + v[j] >= v[mij] )
                    s = mij + 1;
                else
                    d = mij - 1;
            }
            t = t + d - j;
        }
    fout<<t;
    return 0;
}