#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
int n,i,a[1000],st,dr,nr;
int main()
{
ifstream fin ("nrtri.in");
ofstream fout("nrtri.out");
fin>>n;
for(i=1;i<=n;i++)
    fin>>a[i];
sort(a+1,a+n+1);
for(i=3;i<=n;i++)
{
    st=1;
    dr=i-1;
    while(st<dr)
    {
        if(a[st]+a[dr]>=a[i])
         {
             nr=nr+ dr-st;
              dr--;
                      }
         else
            st++;
    }
}
fout<<nr;
}