#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
ifstream r("nrtri.in");
ofstream w("nrtri.out");
int v[801];
int main()
{
    int n, x=0, y=1, yy, z=2, zz, nr=0, cnt=0;
    r>>n;
    for(int i=0; i<n; i++)
    {
        r>>v[i];
    }
    sort(v, v+n);
    while(x<=n-3)
    {
        yy=y;
        zz=z;
        while(yy<=n-2)
        {
            while(v[x]+v[yy]>=v[zz] && zz<=n-1)
            {
                zz++;
                cnt++;
            }
            yy++;
            nr+=cnt;
            cnt--;
       }
        z++;
        y++;
        x++;
        cnt=0;
    }
    w<<nr;
    return 0;
}