#include <fstream>
#include <algorithm>
using namespace std;
ifstream f("nrtri.in");
ofstream g("nrtri.out");
const int NMAX =1e3 + 5;
int a[NMAX];
int t;
int main()
{
	int n;
	f >> n;
	for(int i = 1; i <= n; i++)
		f >> a[i];
	sort(a + 1, a + 1 + n);
	for(int i = 1; i < n - 1; i++)
		for(int j = i + 1; j < n; j++)
		{
			int s = a[i] + a[j];
			int ind = lower_bound(a + j, a + 1 + n, s + 1) - a - 1;
			t += ind - j;
		}
	g << t;
}