#include <fstream>
#include <algorithm>
using namespace std;
ifstream cin("nrtri.in");
ofstream cout("nrtri.out");
const int NMAX=1005;
int v[NMAX];
int bs_right(int st,int dr,int x)
{
    int med,last=-1;
    while(st<=dr)
    {
        med=(st+dr)/2;
        if(x>=v[med])
        {
            last=med;
            st=med+1;
        }
        else
            dr=med-1;
    }
    return last;
}
int main()
{
    int n,i,j,s,poz,cnt=0;
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>v[i];
    sort(v+1,v+n+1);
    for(i=1;i<=n-2;i++)
    {
        for(j=i+1;j<=n-1;j++)
        {
            s=v[i]+v[j];
            poz=bs_right(j+1,n,s);
            if(poz!=-1)
                cnt=cnt+poz-(j+1)+1;
        }
    }
    cout<<cnt;
    return 0;
}