#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];
        for (int j = i + 1; j <= n; ++j)
        {
            int s = v[j];
            for (int h =j + 1; h <= n; ++h)
            {
                int l = v[h];
                if (k + s >= l)
                    ++sol;
                else
                    break;
            }
        }
    }
    cout << sol;
    return 0;
}