#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin("nrtri.in");
ofstream fout("nrtri.out");
int cb(long v[], int l, int x)
{
    int st=1,dr=l,mij;
    while(st<=dr)
    {
        mij=(st+dr)/2;
        if(v[mij]<=x)
            st=mij+1;
        else
            dr=mij-1;
    }
    return dr;
}
long v[3002];
int main()
{
    int n,c=0;
    long long s=0;
    fin>>n;
    for(int i=1;i<=n;++i)
        fin>>v[i];
    sort(v+1,v+n+1);
    for(int i=1;i<=n-2;++i)
        for(int j=i+1;j<=n-1;++j)
        {
            s=v[i]+v[j];
            c+=cb(v,n,s)-j;
        }
    fout<<c;
}