#include <iostream>
#include<fstream>
#include<algorithm>
using namespace std;
ifstream f("nrtri.in");
ofstream g("nrtri.out");
int main()
{
    int n, i, k, j, v[30001], nrtri=0;
    f >> n;
    for(int i = 0; i < n; i ++)
        f >> v[i];
    sort(v, v + n);
    for(i = 0; i < n - 2; i ++)
        for(k = i + 1; k < n - 1; k ++)
        {
            j = k;
            while((j < n - 1) and (v[i] + v[k]) >= v[j + 1])
            {
                nrtri++;
                j++;
            }
        }

    g << nrtri;
    return 0;
}