#include <bits/stdc++.h>
using namespace std;
int v[10005];
int main()
{
    freopen("nrtri.in","r",stdin);
    freopen("nrtri.out","w",stdout);
    int n,i,j;
    scanf("%d",&n);
    for(i=1;i<=n;i++)scanf("%d",&v[i]);
    sort(v+1,v+n+1);
    int sum=0;
    for(i=1;i<n-1;i++)
        for(j=i+1;j<n;j++)
    {
        int st=j+1,dr=n;
        while(st<=dr)
        {
            int med=(st+dr)/2;
            if(v[med]>(v[i]+v[j]))dr=med-1;
            else
                st=med+1;
        }
        sum+=dr-j;
    }
    printf("%d\n",sum);
    return 0;
}