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