#include <fstream>
#include <algorithm>
using namespace std;
int main()
{
    ifstream f("nrtri.in");
    ofstream g("nrtri.out");
    int n,i,ii,iii,v[830],c=0;
    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(ii=i+1;ii<n;ii++)
            for(iii=ii+1;iii<=n&&v[i]+v[ii]>=v[iii];iii++)
                c++;
    g<<c;
}