#include <fstream>
#include <algorithm>
using namespace std;
ifstream in("nrtri.in");
ofstream out("nrtri.out");
const int NMAX = 800;
int n, v[NMAX + 5], cnt;
int caut_bin(int i, int j)
{
    int st = j + 1, dr = n, mij, last = -1;
    while (st <= dr)
    {
        mij = (st + dr) / 2;
        if (v[mij] <= v[i] + v[j])
        {
            last = mij;
            st = mij + 1;
        }
        else
        {
            dr = mij - 1;
        }
    }
    return last;
}
int main()
{
    in >> n;
    for (int i = 1; i <= n; i++)
    {
        in >> v[i];
    }
    sort(v + 1, v + n + 1);
    for (int i = 1; i < n - 1; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            int k = caut_bin(i, j);
            if (k != -1)
            {
                cnt += k - j;
            }
        }
    }
    out << cnt;
    return 0;
}