#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;
            }
    for(i=1; i<=n-2; i++)
        for(j=i+1; j<=n-1; j++)
            for(k=j+1; k<=n && v[i]<=v[j]+v[k]; k++)
                    nr++;
    cout<<nr;
    return 0;
}