#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin("nrtri.in");
ofstream fout("nrtri.out");
int n,i,j,k,p,u,mij,nr,v[1000],sol;
int main()
{
    fin >>n;
    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++)
        {
            p=j+1;
            u=n;
            sol=-1;
            while (p<=u)
            {
                mij=(p+u)/2;
                if (v[i]+v[j]>=v[mij]) {sol=mij;p=mij+1;}
                else u=mij-1;
            }
            if (sol!=-1) nr=nr+sol-j;
        }
    }
    fout <<nr;
    return 0;
}