#include <fstream>
#include <algorithm>
using namespace std;
int v[30005];
int bs(int st,int dr,int x){
    int last=st-1,mij;
    while(st<=dr){
        mij=(st+dr)/2;
        if(v[mij]<=x){
            st=mij+1;
            last=mij;
        } else {
            dr=mij-1;
        }
    }
    return last;
}
int main()
{
    ifstream fin("nrtri.in");
    ofstream fout("nrtri.out");
    int i,s=0,j,n;
    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-1;++j){
            s+=bs(j+1,n,v[i]+v[j])-j;
        }
    }
    fout<<s;
    return 0;
}