#include <fstream>
#include <algorithm>
#include <cmath>
using namespace std;
ifstream f("nrtri.in");
ofstream g("nrtri.out");
int n,i,j,k;
int st,dr,m;
int poz1,poz2,rez;
int v[805];
int main()
{
    f>>n;
    for (i=1;i<=n;i++)
        f>>v[i];
    sort(v+1,v+n+1);
    for (i=1;i<=n-2;i++)
    {
        for (j=i+1;j<=n-1;j++)
        {
           for (k=j+1;k<=n && v[i]+v[j]>=v[k];k++)
            rez++;
        }
    }
    g<<rez;
    return 0;
}