#include <bits/stdc++.h>
using namespace std;
int v[801];
ifstream in ("nrtri.in");
ofstream out ("nrtri.out");
int main()
{
	int n, i, j, h, c=0;
	in >> n;
	for(i=1;i<=n;i++)
	in >> v[i];
	sort(v+1,v+n+1);
	for(i=1;i<=n-2;i++)
		for(j=1+i;j<=n-1;j++)
			for(h=1+j;h<=n;h++)
				if(v[h]<=v[i]+v[j])
				c++;
				else
				break;
	out << c;
	return 0;
}