#include <bits/stdc++.h>
using namespace std;
ifstream ci("nrtri.in");
ofstream cou("nrtri.out");
int n,v[802];
int cautarenr(int st,int dr,int a)
{
    int mijval,mijind,rasp=0;
    while(st<=dr) //cout<<st<<" "<<dr<<endl;
    {
        mijind=(st+dr)/2;
        mijval=v[mijind];
        if(mijval>a)
        {
            dr=mijind-1;
        }
        else
        {
            rasp=mijind;
            st=mijind+1;
        }


    }
    return rasp;

}

int main()
{
    int i,j,cn=0,k;
    ci>>n;
    for(i=1; i<=n; i++)
    {
        ci>>v[i];
    }
    sort(v+1,v+n+1);
    // cout<<cautarenr(3,n,6);
    for(i=1; i<=n-2; i++)
    {
        for(j=i+1; j<=n-1; j++)
        {
            k=cautarenr(j+1,n,v[i]+v[j]);
               if(k)
        {
            cn+=k-j;
        }
    }
}
cou<<cn;
}