/*#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
long long rasp;
long i,j,q,v[1000],n,st,dr,mij;
int main()
{
    freopen("nrtri.in","r",stdin);
    freopen("nrtri.out","w",stdout);
    scanf("%ld",&n);
    for (i=1;i<=n;i++) scanf("%ld",&v[i]);
    sort(v+1,v+n+1);
    rasp=0;
    for (i=1;i<=n-1;i++)
        for (j=i+1;j<=n;j++)
    {
        st=j+1; dr=n;
        mij=(st+dr)/2;
        while (st<dr)
        {
            mij=(st+dr)/2;
            if (v[mij]>v[i]+v[j]) dr=mij-1;
            else if (v[j]>v[i]+v[mij]) st=mij+1;
            else break;
        }
        for (q=mij;q<=n;q++)
            if ((v[i]+v[j]>=v[q]) && (v[i]+v[q]>=v[j]) && (v[j]+v[q]>=v[i]) && (i!=q) && (j!=q))
            {
                rasp++;
                //printf("%ld %ld %ld\n",v[i],v[j],v[q]);
            }
            else if ((v[i]+v[j]<v[q]) || (v[i]+v[q]<v[j]) || (v[j]+v[q]<v[i])) break;
        for (q=mij-1;q>=j+1;q--)
            if ((v[i]+v[j]>=v[q]) && (v[i]+v[q]>=v[j]) && (v[j]+v[q]>=v[i]) && (i!=q) && (j!=q))
            {
                rasp++;
                //printf("%ld %ld %ld\n",v[i],v[j],v[q]);
            }
            else if ((v[i]+v[j]<v[q]) || (v[i]+v[q]<v[j]) || (v[j]+v[q]<v[i])) break;
        //printf("NU\n");
    }
    printf("%lld\n",rasp);
    return 0;
}*/
#include <cstdio>
#include <algorithm>
using namespace std;
long v[1000],i,j,k,n,rasp;
int main()
{
    freopen("nrtri.in","r",stdin);
    freopen("nrtri.out","w",stdout);
    scanf("%ld",&n);
    for (i=1;i<=n;i++) scanf("%ld",&v[i]);
    rasp=0;
    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++) rasp++;
    printf("%ld",rasp);
    return 0;
}