#include <fstream>
#include <algorithm>
using namespace std;
ifstream cin("nrtri.in");
ofstream cout("nrtri.out");
int v[1005];
int bs_right (int st,int dr,int x)
{
    int med,last=-1;
    med=(st+dr)/2;
    while (st<=dr)
    {
        med=(st+dr)/2;
        if (v[med] <= x){
            st=med+1;last=med;
        }
        else
           dr=med-1;
    }
    return last;
}
int main()
{
    int i,j,n,s,poz,cnt=0;
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>v[i];
    sort(v+1,v+n+1);
    for(i=1;i<n;i++)
    for(j=i+1;j<=n;j++){
        s=v[i]+v[j];
        poz=bs_right(j+1,n,s);
        if(poz!=-1)
            cnt+=poz-(j+1)+1;
    }
    cout<<cnt;
    return 0;
}