#include <fstream>
#include <algorithm>
using namespace std;
ifstream in("nrtri.in");
ofstream out("nrtri.out");
int n,v[805],i,j,k,rez,gasit2;
void citire()
{
    in>>n;
    for(i=1; i<=n; i++)
        in>>v[i];
    sort(v+1,v+n+1);
}
void cautare()
{
    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++;
}
void afisare()
{
    out<<rez;
}
int main()
{
    citire();
    cautare();
    afisare();
    return 0;
}