#include <fstream>
#define N 805
using namespace std;
ifstream fin("nrtri.in");
ofstream fout("nrtri.out");
int Triunghi(int a, int b, int c)
{
    if(c<= a+b )
        return 1;
    return 0;
}
void Sortare(int n, int a[])
{
    int i, ordo=0;
    int aux;
    while(ordo==0)
    {
        ordo=1;
        for(i=1; i<=n-1; i++)
            if(a[i]>a[i+1])
            {
                aux=a[i];
                a[i]=a[i+1];
                a[i+1]=aux;
                ordo=0;
            }
    }
}

int main()
{
    int n, a[N], i, j, ct=0, k;
    fin >> n;
    for(i=1; i<=n ; i++)
        fin>>a[i];
    Sortare(n, a);
    for(i=1; i<=n-2; i++)
    {
        k=i+2;
        for(j=i+1; j<=n-1; j++)
        {
            while(Triunghi(a[i], a[j], a[k])==1 &&  k<=n)
                k++;
            if (k>j)
                ct=ct+k-j-1;
        }
    }
    fout<<ct;
    return 0;
}