#include <cstdio>
#include <algorithm>
using namespace std;
long v[1000],i,j,k,n,rasp;
int main()
{
    freopen("nrtri.in","r",stdin);
    freopen("nrtri.out","w",stdout);
    scanf("%ld",&n);
    for (i=1;i<=n;i++) scanf("%ld",&v[i]);
    rasp=0;
    sort(v+1,v+n+1);
    for (i=1;i<=n;i++)
        for (j=i+1;j<=n;j++)
            for (k=j+1;k<=n;k++) if (v[k]<=v[i]+v[j]) rasp++;
                                    else break;
    printf("%ld",rasp);
    return 0;
}