#include <bits/stdc++.h>
using namespace std;
ifstream f("nrtri.in");
ofstream g("nrtri.out");
int n, i, j, v[1001], nr, m, dr, st;
int main()
{   f >> n;
    for ( i=1; i<=n; i++ )
        f >> v[i];
    sort ( v+1, v+n+1 );
    for ( i=1; i<n-1; i++ )
        for ( j=i+1; j<n; j++ )
            {
                st = j + 1; dr = n;
                while ( st <= dr )
                    {
                        m = ( st + dr )/2;
                        if ( v[i] + v[j] >= v[m] )
                            st = m + 1;
                        else dr = m - 1;
                    }
                nr = nr + dr - j;
            }
    g << nr;
    return 0;
}