#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
    freopen("nrtri.in","r",stdin);
    freopen("nrtri.out","w",stdout);
    int n, i , j, v[805], cnt = 0, st , dr , mij;
    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++)
        {
            st=j+1;
            dr=n;
            mij=(st+dr)/2;
            while(st<=dr)
            {
                if(v[i]+v[j]>=v[mij])
                    st = mij+1;
                else
                    dr = mij-1;
                mij=(st+dr)/2;
            }
            cnt += dr-j;
        }
    }
    printf("%d",cnt);
    return 0;
}