#include <fstream>
#include <iostream>
#include <algorithm>
using namespace std;
ifstream f("nrtri.in");
ofstream g("nrtri.out");
int n, i,v[801],aux[799], st, dr, mij, sum,j;
int main()
{
  f>>n;
  for (i=1;i<=n;i++)
    f>>v[i];
  sort(v+1,v+n+1);
  for (i=1;i<=n-2;i++)
  {
    for(j=i+1;j<=n-1;j++)
    {int s=v[i]+v[j];
    st=j+1;
    dr=n;
    mij=(st+dr)/2;
    while(st<=dr)
    {
      if(v[mij]<=s)st=mij+1;
      else if(v[mij]>s)dr=mij-1;
      mij=(st+dr)/2;
    }
    sum+=dr-j;}
  }
  g<<sum;
  return 0;
}