#include <stdio.h>
#include <algorithm>
using namespace std;
int v[2001];
int main()
{
    FILE *fin,*fout;
    fin=fopen("nrtri.in","r");
    fout=fopen("nrtri.out","w");
    int n,i,j,mij,poz,st,dr,x,s=0;
    fscanf(fin,"%d",&n);
    for(i=1;i<=n;i++){
        fscanf(fin,"%d",&v[i]);
    }
    sort(v+1,v+n+1);
    for(i=1;i<=n-2;i++){
        for(j=i+1;j<=n-1;j++){
            x=v[i]+v[j];
            st=j+1;
            dr=n;
            poz=-1;
            while(st<=dr){
                mij=(st+dr)/2;
                if(v[mij]>x)
                    dr=mij-1;
                else{
                    poz=mij;
                    st=mij+1;
                }
            }
            if(poz!=-1)
                s=s+poz-j;
        }
    }
    fprintf(fout,"%d",s);
    fclose(fin);
    fclose(fout);
    return 0;
}