#include <fstream>
#define N 1000
using namespace std;
ifstream fin("nrtri.in");
ofstream fout("nrtri.out");
int n,a[N];
void QSort(int st,int dr)
{   if(st<dr)
    {   int m=st+(dr-st)/2,aux=a[st];
        a[st]=a[m];
        a[m]=aux;
        int i=st,j=dr,d=0;
        while(i<j)
        {   if(a[i]>a[j])
            {   aux=a[i];
                a[i]=a[j];
                a[j]=aux;
                d=1-d;
            }
            i+=d;
            j-=(1-d);
        }
        QSort(st,i-1);
        QSort(i+1,dr);
    }
}
int VF(int i,int j)
{
    int x=a[i]+a[j],st=j+1,dr=n,r=0,m;
    while(st<=dr)
    {
        m=st+(dr-st)/2;
        if(a[m]>x) dr=m-1;
        else r=m,st=m+1;
    }
    return r;
}
int main()
{
    int i;
    fin>>n;
    for(i=1; i<=n; ++i) fin>>a[i];
    QSort(1,n);
    int j,k,ct=0;
    bool ok;
    for(i=1; i<=n; ++i)
        for(j=i+1; j<=n; ++j)
        {
            k=VF(i,j);
            if(k!=0) ct+=k-j;
        }
    fout<<ct;
    return 0;
}