#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int nr,st,dr,mij,rez,a[809],n,i,j;
int main()
{
    freopen("nrtri.in","r",stdin);
    freopen("nrtri.out","w",stdout);
    scanf("%d",&n);
    for(i=1;i<=n;i++)
        scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    for(i=1;i<=n-2;i++)
        for(j=i+1;j<=n-1;j++)
        {
            st=j+1;
            dr=n;
            rez=j;
            while(st<=dr)
            {
                mij=(st+dr)/2;
                if(a[i]+a[j]>=a[mij])
                {
                    rez=mij;
                    st=mij+1;
                }
                else
                    dr=mij-1;
            }
            nr+=rez-j;
        }
    cout<<nr;
    return 0;
}