#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin("nrtri.in");
ofstream fout("nrtri.out");
int n,v[1001];
bool verificare(int a, int b, int c);
int cautbin(int x, int y)
{
     int st=y+1;
    int dr=n;
    int sol=-1;
    while(st<=dr)
    {
        int mij = (st + dr) / 2;
        if(verificare(v[x], v[y], v[mij]))
        {
            sol=mij;
            st=mij+1;
        }
        else
        {
            dr=mij-1;
        }
    }
    return sol;
}
bool verificare(int a, int b ,int c)
{
    if(a+b>=c && a+c>=b && b+c>=a)
        return true;
    else
        return false;
}
int contor=0;
int main()
{
   fin>>n;
   for( int i =1;i<=n;i++)
    fin>>v[i];
   sort(v, v+n+1);
   for(int i=1;i<=n-2;i++)
        for(int j=i+1;j<=n-1;j++)
   {
       int z=cautbin(i,j);
       if(z!=-1)
            contor+=z-j;
   }
   fout<<contor;
}