#include<cstdio>
#include<algorithm>
using namespace std;
int a[800],l,i,j,k,n;
int main()
{
    freopen("nrtri.in","r",stdin),freopen("nrtri.out","w",stdout),scanf("%d",&n);
    for(i=0;i<n;++i)
        scanf("%d",a+i);
    sort(a,a+n);
    for(i=0;i<n-2;++i)
        for(j=i+1;j<n-1;++j) {
            for(k=j+1;k<n&&a[i]+a[j]>=a[k];++k);
            l+=k-j-1;
        }
    printf("%d",l);
    return 0;
}