#include <fstream>
#include <algorithm>
using namespace std;
ifstream cin ("nrtri.in");
ofstream cout ("nrtri.out");
int n,i,j,l,x,y,z,v[100005],ok,nr,r,mij,k;
int main()
{
    cin >>n;
    for (i=1; i<=n; i++)
    {
        cin >>v[i];
    }
    sort(v+1, v+n+1);
    for (i=1; i<=n; i++)
    {
        x=v[i];
        for (j=i+1; j<=n; j++)
        {
            y=v[j];
            l=j+1;
            r=n;
            k=-1;
            while (l<=r)
            {
                mij=(l+r)/2;
                if (x+y>=v[mij])
                {
                    k=mij;
                    l=mij+1;
                }
                else
                {
                    r=mij-1;
                }
            }
            if (k!=-1) nr=nr+k-j;
        }
    }
    cout <<nr;
    return 0;
}