#include <iostream>
#include <algorithm>
#include <fstream>
using namespace std;
int v[801];
int main()
{
    int N, r, pas, i, j, x, p=0;
    ifstream in("nrtri.in");
    ofstream out("nrtri.out");
    in>>N;

    for (i=1; i<=N; i++)
        in>>v[i];
    sort (v+1,v+N+1);
    for (i=1; i<=N-2; i++)
    {
        for (j=i+1; j<=N-1; j++)
        {
            x=v[i]+v[j];
            r=0;
            pas=1<<9;

            while (pas!=0)
            {
                if ((pas+r)<=N && v[pas+r]<=x)
                    r+=pas;
                pas/=2;
            }
            p+=r-j;
        }
    }
    out<<  p << endl;
    out.close ();
    in.close ();
    return 0;
}