#include <fstream>
#include <algorithm>
using namespace std;
ifstream in("nrtri.in");
ofstream out("nrtri.out");
int v[801];
int main()
{
    int cnt=0,n,i,j,k;
    in>>n;
    for(int i=1;i<=n;i++)
        in>>v[i];
    sort(v+1,v+n+1);
    for(i=1;i<=n;i++)
        for(j=i+1;j<=n;j++)
            for(k=j+1;v[k]<=(v[i]+v[j]) && k <=n ;k++)
                cnt++;
    out<<cnt;
    return 0;
}