#include <iostream>
#include <fstream>
#define daca(a,b)if(a>b)
using namespace std;
ifstream in("nrtri.in");
ofstream out("nrtri.out");
int v[803],n,i,j,k,sol;
void citire()
{
    in>>n;
    for(i=1;i<=n;i++)in>>v[i];
}
void sortare()
{
    int ok,aux;
    do{
        ok=0;
        for(i=1;i<=n-1;i++)
        {
            daca(v[i],v[i+1])
            {
                aux=v[i];
                v[i]=v[i+1];
                v[i+1]=aux;
                ok=1;
            }
        }
    }while(ok);
}
int triunghi(int a,int b,int c)
{
    if(a+b>=c&&a+c>=b&&b+c>=a)return 1;
    else return 0;
}
int main()
{
    citire();
    sortare();
    for(i=1;i<=n-2;i++)
    {
        for(j=i+1;j<=n-1;j++)
        {
            for(k=j+1;k<=n&&triunghi(v[i],v[j],v[k]);k++)sol++;
        }
    }
    out<<sol;
    return 0;
}