#include <fstream>
#include <math.h>
#include <algorithm>
using namespace std;
ifstream fin ("nrtri.in");
ofstream fout ("nrtri.out");
int v[1005];
int main()
{
    int n,i,s=0,j,ok;
    fin>>n;
    for(i=1;i<=n;i++)
        fin>>v[i];
    sort(v+1,v+n+1);
    for(i=1;i<=n-2;i++)
    {
        ok=i+2;
        for(j=i+1;j<=n-1;j++)
        {
            while(ok<=n && v[ok]<=v[i]+v[j])
                ok=ok+1;
            if(ok>j)
                s=s+ok-j-1;
        }
    }
    fout<<s;
    return 0;
}