#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin("nrtri.in");
ofstream fout("nrtri.out");
int v[805],n,midi,ok;
void cautbin(int x,int j)
{
    int left, right, mid;
    left=j+1;
    ok=0;
    right=n;
    while(left<=right)
    {
        mid=(left+right)/2;
        if(v[mid]<=x)
        {
           midi=mid;
           left=mid+1;
           ok=1;
        }
        else
        {
            right=mid-1;
        }
    }
}
int main()
{
    int i,j,s,a=0;
    fin>>n;
    for(i=1;i<=n;i++)
    {
        fin>>v[i];
    }
    sort(v+1,v+n+1);
    for(i=1;i<=n;i++)
    {
        for(j=i+1;j<=n;j++)
        {
            s=v[i]+v[j];
            cautbin(s,j);
            if(ok)
                {
                    if(v[midi]+v[i]>=v[j]&&v[midi]+v[j]>=v[i])
                        a=a+midi-j;
                }
            s=0;
        }
    }
    fout<<a;
    return 0;
}