#include <stdio.h>
#include <algorithm>
using namespace std;
int v[2001];
int main()
{
    freopen("nrtri.in","r",stdin);
    freopen("nrtri.out","w",stdout);
    int n,i,nr,ct=0,j,s,st,dr,poz,m;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&v[i]);
    }
    sort(v+1,v+1+n);
    for(i=1;i<=n-2;i++)
    {
        for(j=i+1;j<=n-1;j++)
        {
            s=v[i]+v[j];
            st=j+1;
            dr=n;
            poz=-1;
            while(st<=dr)
            {
                m=(st+dr)/2;
                if(v[m]>s)
                {
                    dr=m-1;
                }
                else
                {
                    st=m+1;
                    poz=m;
                }
            }
            if(poz!=-1)
            {
                ct=ct+poz-j;
            }
        }
    }
    printf("%d",ct);
    return 0;
}