#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
int v[801];
int main()
{
  freopen("nrtri.in","r",stdin);
  freopen("nrtri.out","w",stdout);
  int n,mij,st,dr,i,y,x,cnt=0,j,cap1,cap2;
  scanf("%d",&n);
  for(i=1;i<=n;i++)
    scanf("%d",&v[i]);
  sort(v+1,v+n+1);
  for(i=1;i<n-1;i++)
  {
    x=v[i];
    for(j=i+1;j<n;j++)
    {
      cap1=0;
      y=v[j];
      st=j+1;
      dr=n;
      while(st<=dr)
      {
        mij=(st+dr)/2;
        if(x+y<v[mij])
          dr=mij-1;
        else
        {
          st=mij+1;
          if(x+v[mij]>=y && y+v[mij]>=x)
            if(mij>cap1)
            cap1=mij;
        }
      }
      if(cap1!=0)
      {
          st=j+1;
          dr=n;
          cap2=801;
          while(st<=dr){
            mij=(st+dr)/2;
            if(x+v[mij]<y || y+v[mij]<x)
              st=mij+1;
            else
            {
                dr=mij-1;
                if(x+y>=v[mij])
                  if(mij<cap2)
                    cap2=mij;
            }
          }
          cnt+=cap1-cap2+1;
      }
    }
  }
  printf("%d",cnt);
  return 0;
}