#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin ("nrtri.in");
ofstream fout("nrtri.out");
int v[1000];
int main()
{
    int n, sol = 0;
    fin >> n;
    for(int i = 1; i <= n; ++i) fin >> v[i];
    fin.close();
    sort(v+1, v+n+1);
    for(int i = 1; i < n-1; ++i)
        for(int j = i+1; j < n; ++j)
        {
            int st = j, dr = n, mij, aux;
            while(st <= dr)
            {
                mij = (st+dr) / 2;
                if(v[i]+v[j] >= v[mij])
                {
                    aux = mij;
                    st = mij+1;
                }
                else dr = mij-1;
            }
            sol += (aux - j);
        }
    fout << sol;
    fout.close();
    return 0;
}