#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
ifstream f("nrtri.in");
ofstream g("nrtri.out");
int main()
{
    long long a[1005];
    int contor=0;
    long long n;
    f>>n;
    for (int i = 1; i<=n;i ++)
        f>>a[i];
    sort(a+1,a+n+1);
    for (int i=1; i<=n; i++)
        for(int j=i+1; j<=n; j++)
            for (int k=j+1; k<=n; k++)
                if (a[i]+a[j]>=a[k])
                    contor++;
                    else break;
    g<<contor;
    return 0;
}