#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
int main()
{
    ifstream in("nrtri.in");
    ofstream out("nrtri.out");
    int x,i,j,n,a[801],nr=0;
    in>>n;
    for(i=1; i<=n; i++)
        in>>a[i];
    sort(a+1,a+n+1);
    for(i=1; i<=n; i++)
    {
        x=i+2;
        for(j=i+1; j<=n; j++)
        {
            while(x<=n && a[i]+a[j]>=a[x])
                x++;
            if(x-j-1>0)
                nr=nr+x-j-1;
        }
    }
    out<<nr;
    return 0;
}