#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
ifstream in("nrtri.in");
ofstream out("nrtri.out");
int main()
{
    int n,v[2001],i,s=0,x,y,z;
    in>>n;
    for(i=1;i<=n;i++)
        in>>v[i];
    sort(v+1,v+n+1);
    for(x=1;x<n-1;x++)
    {
        for(y=x+1;y<n;y++)
        {
            z=v[y]+v[x];
            int pos=0,msk;
            for(msk=1<<30;msk>0;msk/=2)
            if(pos+msk<=n && v[pos+msk]<=z)
            pos+=msk;
            if(pos>0)
            s=s+(pos-y);
        }
    }
    out<<s;
    return 0;
}