#include <fstream>
#include <algorithm>
using namespace std;
ifstream in("nrtri.in");
ofstream out("nrtri.out");
int main()
{
    int count,a[801],n,k;
    in>>n;
    for(int i=0;i<n;i++)
    {
        in>>a[i];
    }
    sort(a,a+n);
    count = 0;
    for (int i = 0; i < n - 2; ++i)
    {
        k = i + 2;
        for (int j = i + 1; j < n - 1; ++j)
        {
            while (k < n && a[k] <= a[i] + a[j])
                ++k;
            if (k > j)
                count += k - j-1;
        }
    }
        out<<count;
        return 0;
}