#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin("nrtri.in");
ofstream fout("nrtri.out");
const int NMAX = 800;
int v[NMAX + 5];
int bs(int i, int j, int n)
{
    int rez = 0, pas = 1 << 10, x = v[i] + v[j];
    while(pas)
    {
        if (rez + pas < n && v[rez + pas] <= x)
            rez += pas;
        pas >>= 1;
    }
    return rez;
}
int main()
{
    int n, i, j, k, s = 0;
    fin >> n;
    for (i = 0; i < n; ++i)
    {
        fin >> v[i];
    }
    sort(v, v + n);
    for(i = 0; i < n - 2 ; ++i)
    {
        for(j = i + 1 ; j < n - 1; ++j)
        {
            k = bs(i, j, n);
            if (k > j)
            {
                s += k - j;
            }
        }
    }
    fout << s;
    return 0;
}