#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
int main()
{
    freopen("nrtri.in","r",stdin);
    freopen("nrtri.out","w",stdout);
    int n,v[801],i,j,s,d,r=0,mij,rez;
    cin>>n;
    for(i=1; i<=n; i++)
        cin>>v[i];
    sort(v+1,v+n+1);
    for(i=1; i<=n; i++)
        for(j=i+1; j<=n; j++)
        {
            s=j+1;
            d=n;
            rez=-1;
            while(d>=s)
            {
                mij=(d+s)/2;
                if(v[i]+v[j]>=v[mij])
                    s=mij+1;
                else
                {
                    rez=mij;
                    d=mij-1;
                }
            }
            if(rez!=-1)
                r=r+rez-j-1;
            else
                r=r+n-j;
        }
    cout<<r;
    return 0;
}