#include<fstream>
#include<algorithm>
using namespace std;
int v[801];
int main(){
    ifstream cin("nrtri.in");
    ofstream cout("nrtri.out");
int n,x,y,i,j,c=0,st,dr,mij,poz=-1;
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];
        poz=-1;
        st=j+1;
        dr=n;
        while(st<=dr){
            mij=(st+dr)/2;
            if(v[mij]>x+y)
                dr=mij-1;
            else{
                poz=mij;
                st=mij+1;
            }
        }
        if(poz!=(-1))
            c=c+(poz-j);
    }
}
cout<<c;
return 0;
}