#include <fstream>
#include <algorithm>
using namespace std;
ifstream cin ("nrtri.in");
ofstream cout ("nrtri.out");
int v[802];
int main()
{
    int n,sol = 0;
    cin >> n;
    for (int i =1; i<= n; ++i)
    {
        cin >> v[i];
    }
    sort (v + 1,v + n + 1);
    for (int i =1; i<= n; ++i)
    {
        int k = v[i];
        int h = i + 2;
        for (int j = i + 1; j <= n; ++j)
        {
            int s = v[j];
            int st = j + 1;
            int dr = n;
            while (h <= n and k + s >= v[h])
                ++h;
            --h;
            sol += h - j;
        }
    }
    cout << sol;
    return 0;
}