#include <iostream>
#include <algorithm>
#include <fstream>
#define Maxx 1001
using namespace std;
ifstream f("nrtri.in");
ofstream g("nrtri.out");
long long N, A[Maxx],cnt;
int main()
{
    f >> N;
    for ( int i=1;i<=N;i++ )
        f >> A[i];
    sort ( A+1,A+N+1 );
    for ( int i=1;i<=N-2;i++ )
        for ( int j=1+i;j<=N-1;j++ )
            for ( int k=1+j;k<=N &&  A[k]<= A[i]+A[j]; k++ )
                cnt++;
    g << cnt;
    return 0;
}