#include <bits/stdc++.h>
using namespace std;
ifstream in("nrtri.in");
ofstream out("nrtri.out");
int main()
{
    int n,i,j,k,v[2001],nt=0;
    in>>n;
    for (i=1; i<=n; i++)
        in>>v[i];
    sort(v+1,v+n+1);
    for (i=1; i<=n-2; i++)
    {
        k=i+2;
        for (j=i+1; j<=n; j++)
        {
            while (k<=n&&v[i]+v[j]>=v[k])
                k++;
            if (k>j)
                nt+=k-j-1;
        }
    }
    out<<nt;
    return 0;
}