#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin("nrtri.in");
ofstream fout("nrtri.out");
int main()
{
    int N,i,a[805],contor=0,j,h;
    fin >> N;
    for (i=1;i<=N;++i)
    {
        fin >> a[i];
    }
    sort(a+1,a+N+1);
    for (i=1;i<=N;++i)
    {
        for (j=i+1;j<=N;++j)
        {
            for (h=j+1;h<=N;++h)
            {
                if (a[i]+a[j]>=a[h])
                {
                    ++contor;
                }
                    else
                    {
                        break;
                    }
            }
        }
    }
    fout << contor;
    return 0;
}