#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
ifstream in ("nrtri.in");
ofstream out("nrtri.out");
int x[801],n;
int main()
{
    int piv1,piv2,piv3;
    long long int s=0;
    in>>n;
    for(int i=0;i<n;++i)
        in>>x[i];
    sort(x,x+n);
    for(piv1=0;piv1<n-2;++piv1)
        for(piv2=piv1+1;piv2<n-1;++piv2)
            for(piv3=piv2+1;piv3<n;++piv3)
                if(x[piv1]+x[piv2]>=x[piv3])++s;
                else break;
    out<<s;
    return 0;
}