#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin("nrtri.in");
ofstream fout("nrtri.out");
const int NMAX=800;
int v[NMAX+5];
int main()
{
    int n,dr,st,med,i,j,s,last,rasp=0,k;
    fin>>n;
    for(i=1;i<=n;i++)
    {
        fin>>v[i];
    }
    sort(v+1,v+n+1);
    for(i=1;i<n-1;i++)
    {
        for(j=i+1;j<n;j++)
        {
            s=v[i]+v[j];
            dr=n;
            st=j+1;
            last=-1;
            while(st<=dr)
            {
                med=(st+dr)/2;
                if(s>=v[med])
                {
                    last=med;
                    st=med+1;
                }
                else
                {
                    dr=med-1;
                }
            }
            if(last!=-1)
            rasp+=last-j;
        }
    }
    fout<<rasp;
    return 0;
}