#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
ifstream in("nrtri.in");
ofstream out("nrtri.out");
int v[100001];
int main()
{
    int n, i, j, k, cnt = 0;
    in>>n;
    for (i=1; i<=n; ++i)
    {
        in >> v[i];
    }
    sort(v, v+n+1);
    for (i=1; i<=n-2; ++i)
    {   
        for (j=i+1; j<=n-1; ++j)
        { 
            for (k=j+1; k<=n; ++k)
            {
                if ((v[i]+v[j]) >= v[k])
                    cnt+=1;
                else break;
            }
        }
    }
    out << cnt;
    return 0;
}