#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin("nrtri.in");
ofstream fout("nrtri.out");
int n,i=1,j,v[1000],f,d,nr;
int cb(int st,int dr,int x)
{
  int rez=-2,m;
  while(st<=dr)
  {
   m=(st+dr)/2;
   if(v[m]>x) dr=m-1;
   else if(v[m]<=x)
   {
    st=m+1;
    rez=m;
   }
  }

  return rez;
}
int main()
{
    fin>>n;
    for(i=1;i<=n;i++)
      fin>>v[i];
    sort(v+1,v+n+1);
    for(i=1;i<=n-2;i++)
     for(j=i+1;j<=n-1;j++)
    {
     d=v[i]+v[j];
     nr=cb(j+1,n,d);
     if(nr!=-2)
       f+=nr-j;

    }

    fout<<f;
    return 0;
}