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