#include <bits/stdc++.h>
using namespace std;
ifstream in ("nrtri.in");
ofstream out ("nrtri.out");
int v[2001];
int main()
{
    int n,i,p=0,j,ac,pas;
    in>>n;
    for(i=1;i<=n;i++)
        in>>v[i];
    sort(v+1,v+n+1);
    for(i=1;i<=n;i++)
        for(j=i+1;j<=n;j++)
        {
            pas=1<<9;
            ac=j;
            while(pas)
            {
                if(ac+pas<=n)
                    if(v[i]+v[j]>=v[ac+pas])
                        ac=ac+pas;
                pas>>=1;
            }
            p=p+ac-j;
        }
    out<<p;
    return 0;
}