#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int v[1001];
int cautbin(int x,int n)
{
    int p=1,u=n,poz=-1,m;
    while(p<=u)
    {
        m=(p+u)/2;
        if(x>=v[m])
        {
            poz=m;
            p=m+1;
        }
        else
            u=m-1;
    }
    return poz;
}

int main()
{
    freopen("nrtri.in","r",stdin);
    freopen("nrtri.out","w",stdout);
    int n,nr=0,i,j,poz;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
        scanf("%d",&v[i]);
    sort(v+1,v+n+1);
    for(i=1;i<=n-2;i++)
        for(j=i+1;j<=n-1;j++)
        {
            poz=cautbin(v[i]+v[j],n);
            if(poz!=-1)
                nr+=poz-j;
        }
    cout<<nr;
    return 0;
}