#include <fstream>
#include <algorithm>
using namespace std;
ifstream in ("nrtri.in");
ofstream out ("nrtri.out");
int v[2001],s;
bool ok;
int cbin(int pr,int ul)
{
    int mij,r;
    while (pr<=ul)
    {
        mij=(pr+ul)/2;
        if(s>=v[mij])
        {
            r=mij;
            ok=1;
            pr=mij+1;
        }
        else
            ul=mij-1;
    }
    return r;
}
int main()
{
    int nr,j,i,n,tr=0;
    in>>n;
    for(i=1;i<=n;i++)
    {
        in>>v[i];
    }
    sort(v+1,v+n+1);
    for(i=1;i<=n;i++)
    {
        for(j=i+1;j<=n;j++)
        {
            ok=0;
            s=v[i]+v[j];
            nr=cbin(j+1,n);
            if(ok)
            {
                if(v[nr]+v[i]>=v[j]&&v[nr]+v[j]>=v[i])
                    tr+=(nr-j);
            }
        }
    }
    out<<tr;
    return 0;
}